Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIGRATION: Relax constraints on citations table #573

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions db/migrate/20180206152600_relax_citations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class RelaxCitations < ActiveRecord::Migration
def self.up
# Use longer "text" field
change_column :citations, :title, :text
change_column :citations, :journal, :text
add_column :citations, :notes, :text

# This constraint is draconian and totally unnecessary.
# Other metadata should be plenty sufficient without well-formed page number
execute %q{
ALTER TABLE citations
DROP CONSTRAINT well_formed_citation_page_spec;
}
end

def self.down
change_column :citations, :title, :string
change_column :citations, :journal, :string
remove_column :citations, :notes, :text
execute %q{
ALTER TABLE citations
ADD CONSTRAINT well_formed_citation_page_spec CHECK (pg ~ '^([1-9]\d*(\u2013[1-9]\d*)?)?$');
}
end
end