Make migrations independent of globalize
There are two reasons for this change: 1. Past migrations depending on models will not work once a model is removed, and they won't work if we remove Globalize either 2. We were getting a conflict in the schema file; when run under Rails 5.0, these migrations were generating a different schema than in Rails 5.1, due to the way the `create_translation_table!` method handles the `id: :serial` attribute.
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
class MakeInvestmentMilestonesPolymorphic < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :milestones do |t|
|
||||
t.references :milestoneable, polymorphic: true
|
||||
create_table :milestones, id: :serial do |t|
|
||||
t.string :milestoneable_type
|
||||
t.integer :milestoneable_id
|
||||
t.string "title", limit: 80
|
||||
t.text "description"
|
||||
t.datetime "publication_date"
|
||||
|
||||
t.references :status, index: true
|
||||
t.integer :status_id, index: true
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
reversible do |change|
|
||||
change.up do
|
||||
Milestone.create_translation_table!({
|
||||
title: :string,
|
||||
description: :text
|
||||
})
|
||||
end
|
||||
create_table :milestone_translations do |t|
|
||||
t.integer :milestone_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
change.down do
|
||||
Milestone.drop_translation_table!
|
||||
end
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
t.index :locale
|
||||
t.index :milestone_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
class CreateI18nContentTranslations < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :i18n_contents do |t|
|
||||
create_table :i18n_contents, id: :serial do |t|
|
||||
t.string :key
|
||||
end
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
I18nContent.create_translation_table!(
|
||||
{ value: :text },
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
create_table :i18n_content_translations do |t|
|
||||
t.integer :i18n_content_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
dir.down do
|
||||
I18nContent.drop_translation_table!
|
||||
end
|
||||
t.text :value
|
||||
|
||||
t.index :i18n_content_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class AddBannerTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Banner.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :banner_translations do |t|
|
||||
t.integer :banner_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Banner.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
t.index :banner_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
class AddHomepageContentTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Widget::Card.create_translation_table!(
|
||||
{
|
||||
label: :string,
|
||||
title: :string,
|
||||
description: :text,
|
||||
link_text: :string
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :widget_card_translations do |t|
|
||||
t.integer :widget_card_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Widget::Card.drop_translation_table!
|
||||
t.string :label
|
||||
t.string :title
|
||||
t.text :description
|
||||
t.string :link_text
|
||||
|
||||
t.index :locale
|
||||
t.index :widget_card_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
class AddPollTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Poll.create_translation_table!(
|
||||
{
|
||||
name: :string,
|
||||
summary: :text,
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :poll_translations do |t|
|
||||
t.integer :poll_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Poll.drop_translation_table!
|
||||
t.string :name
|
||||
t.text :summary
|
||||
t.text :description
|
||||
|
||||
t.index :locale
|
||||
t.index :poll_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class AddAdminNotificationTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
AdminNotification.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
body: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :admin_notification_translations do |t|
|
||||
t.integer :admin_notification_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
AdminNotification.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :body
|
||||
|
||||
t.index :admin_notification_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
class AddPollQuestionTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Poll::Question.create_translation_table!(
|
||||
{ title: :string },
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :poll_question_translations do |t|
|
||||
t.integer :poll_question_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Poll::Question.drop_translation_table!
|
||||
t.string :title
|
||||
|
||||
t.index :locale
|
||||
t.index :poll_question_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class AddPollQuestionAnswerTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Poll::Question::Answer.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :poll_question_answer_translations do |t|
|
||||
t.integer :poll_question_answer_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Poll::Question::Answer.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
t.index :locale
|
||||
t.index :poll_question_answer_id, name: "index_85270fa85f62081a3a227186b4c95fe4f7fa94b9"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,42 +1,54 @@
|
||||
class AddCollaborativeLegislationTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Legislation::Process.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
summary: :text,
|
||||
description: :text,
|
||||
additional_info: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
def change
|
||||
create_table :legislation_process_translations do |t|
|
||||
t.integer :legislation_process_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
Legislation::Question.create_translation_table!(
|
||||
{ title: :text },
|
||||
{ migrate_data: true }
|
||||
)
|
||||
t.string :title
|
||||
t.text :summary
|
||||
t.text :description
|
||||
t.text :additional_info
|
||||
|
||||
Legislation::DraftVersion.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
changelog: :text,
|
||||
body: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
|
||||
add_column :legislation_draft_version_translations, :body_html, :text
|
||||
add_column :legislation_draft_version_translations, :toc_html, :text
|
||||
|
||||
Legislation::QuestionOption.create_translation_table!(
|
||||
{ value: :string },
|
||||
{ migrate_data: true }
|
||||
)
|
||||
t.index :legislation_process_id, name: "index_199e5fed0aca73302243f6a1fca885ce10cdbb55"
|
||||
t.index :locale
|
||||
end
|
||||
|
||||
def self.down
|
||||
Legislation::Process.drop_translation_table!
|
||||
Legislation::DraftVersion.drop_translation_table!
|
||||
Legislation::Question.drop_translation_table!
|
||||
Legislation::QuestionOption.drop_translation_table!
|
||||
create_table :legislation_question_translations do |t|
|
||||
t.integer :legislation_question_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
t.text :title
|
||||
|
||||
t.index :legislation_question_id, name: "index_d34cc1e1fe6d5162210c41ce56533c5afabcdbd3"
|
||||
t.index :locale
|
||||
end
|
||||
|
||||
create_table :legislation_draft_version_translations do |t|
|
||||
t.integer :legislation_draft_version_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
t.string :title
|
||||
t.text :changelog
|
||||
t.text :body
|
||||
t.text :body_html
|
||||
t.text :toc_html
|
||||
|
||||
t.index :legislation_draft_version_id, name: "index_900e5ba94457606e69e89193db426e8ddff809bc"
|
||||
t.index :locale
|
||||
end
|
||||
|
||||
create_table :legislation_question_option_translations do |t|
|
||||
t.integer :legislation_question_option_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
t.string :value
|
||||
|
||||
t.index :legislation_question_option_id, name: "index_61bcec8729110b7f8e1e9e5ce08780878597a209"
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
class AddTranslatePages < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
SiteCustomization::Page.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
subtitle: :string,
|
||||
content: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
def change
|
||||
create_table :site_customization_page_translations do |t|
|
||||
t.integer :site_customization_page_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
change_column :site_customization_pages, :title, :string, null: true
|
||||
t.string :title
|
||||
t.string :subtitle
|
||||
t.text :content
|
||||
|
||||
t.index :locale
|
||||
t.index :site_customization_page_id, name: "index_7fa0f9505738cb31a31f11fb2f4c4531fed7178b"
|
||||
end
|
||||
|
||||
def self.down
|
||||
SiteCustomization::Page.drop_translation_table!
|
||||
change_column :site_customization_pages, :title, :string, null: false
|
||||
change_column_null :site_customization_pages, :title, from: false, to: true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
class AddProposalsTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Proposal.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
description: :text,
|
||||
summary: :text,
|
||||
retired_explanation: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :proposal_translations do |t|
|
||||
t.integer :proposal_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Proposal.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :description
|
||||
t.text :summary
|
||||
t.text :retired_explanation
|
||||
|
||||
t.index :locale
|
||||
t.index :proposal_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class AddDebatesTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Debate.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :debate_translations do |t|
|
||||
t.integer :debate_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Debate.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
t.index :debate_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
class AddCommentsTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Comment.create_translation_table!(
|
||||
{
|
||||
body: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :comment_translations do |t|
|
||||
t.integer :comment_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Comment.drop_translation_table!
|
||||
t.text :body
|
||||
|
||||
t.index :comment_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
class AddHomePageToLegislationProcesses < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :legislation_processes, :homepage_enabled, :boolean, default: false
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
Legislation::Process.add_translation_fields! homepage: :text
|
||||
end
|
||||
|
||||
dir.down do
|
||||
remove_column :legislation_process_translations, :homepage
|
||||
end
|
||||
end
|
||||
add_column :legislation_process_translations, :homepage, :text
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
class AddBudgetInvestmentTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Budget::Investment::Translation.without_auditing do
|
||||
Budget::Investment.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
end
|
||||
def change
|
||||
create_table :budget_investment_translations do |t|
|
||||
t.integer :budget_investment_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Budget::Investment.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
t.index :budget_investment_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
class CreateProgressBars < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :progress_bars do |t|
|
||||
create_table :progress_bars, id: :serial do |t|
|
||||
t.integer :kind
|
||||
t.integer :percentage
|
||||
t.references :progressable, polymorphic: true
|
||||
t.string :progressable_type
|
||||
t.integer :progressable_id
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
reversible do |change|
|
||||
change.up do
|
||||
ProgressBar.create_translation_table!({
|
||||
title: :string
|
||||
})
|
||||
end
|
||||
create_table :progress_bar_translations do |t|
|
||||
t.integer :progress_bar_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
change.down do
|
||||
ProgressBar.drop_translation_table!
|
||||
end
|
||||
t.string :title
|
||||
|
||||
t.index :locale
|
||||
t.index :progress_bar_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
class AddActivePollsTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
ActivePoll.create_translation_table!(
|
||||
{
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :active_poll_translations do |t|
|
||||
t.integer :active_poll_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
ActivePollPoll.drop_translation_table!
|
||||
t.text "description"
|
||||
|
||||
t.index :active_poll_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
class AddBudgetTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Budget.create_translation_table!(
|
||||
{
|
||||
name: :string
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :budget_translations do |t|
|
||||
t.integer :budget_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Budget.drop_translation_table!
|
||||
t.string :name
|
||||
|
||||
t.index :budget_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class AddBudgetPhaseTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Budget::Phase.create_translation_table!(
|
||||
{
|
||||
description: :text,
|
||||
summary: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :budget_phase_translations do |t|
|
||||
t.integer :budget_phase_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Budget::Phase.drop_translation_table!
|
||||
t.text :description
|
||||
t.text :summary
|
||||
|
||||
t.index :budget_phase_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
class AddBudgetGroupTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Budget::Group.create_translation_table!(
|
||||
{
|
||||
name: :string
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :budget_group_translations do |t|
|
||||
t.integer :budget_group_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Budget::Group.drop_translation_table!
|
||||
t.string :name
|
||||
|
||||
t.index :budget_group_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
class AddBudgetHeadingTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Budget::Heading.create_translation_table!(
|
||||
{
|
||||
name: :string
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :budget_heading_translations do |t|
|
||||
t.integer :budget_heading_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Budget::Heading.drop_translation_table!
|
||||
t.string :name
|
||||
|
||||
t.index :budget_heading_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user