diff --git a/db/migrate/20180713124501_make_investment_milestones_polymorphic.rb b/db/migrate/20180713124501_make_investment_milestones_polymorphic.rb index 3b9b8d54d..423b76e9f 100644 --- a/db/migrate/20180713124501_make_investment_milestones_polymorphic.rb +++ b/db/migrate/20180713124501_make_investment_milestones_polymorphic.rb @@ -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 diff --git a/db/migrate/20180718115545_create_i18n_content_translations.rb b/db/migrate/20180718115545_create_i18n_content_translations.rb index 478ef6d8e..479b53942 100644 --- a/db/migrate/20180718115545_create_i18n_content_translations.rb +++ b/db/migrate/20180718115545_create_i18n_content_translations.rb @@ -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 diff --git a/db/migrate/20180727140800_add_banner_translations.rb b/db/migrate/20180727140800_add_banner_translations.rb index 710dc8237..36bbb541d 100644 --- a/db/migrate/20180727140800_add_banner_translations.rb +++ b/db/migrate/20180727140800_add_banner_translations.rb @@ -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 diff --git a/db/migrate/20180730120800_add_homepage_content_translations.rb b/db/migrate/20180730120800_add_homepage_content_translations.rb index b8c8a8e74..0d0c95c65 100644 --- a/db/migrate/20180730120800_add_homepage_content_translations.rb +++ b/db/migrate/20180730120800_add_homepage_content_translations.rb @@ -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 diff --git a/db/migrate/20180730213824_add_poll_translations.rb b/db/migrate/20180730213824_add_poll_translations.rb index c4c9b4bbc..9acd6d2f6 100644 --- a/db/migrate/20180730213824_add_poll_translations.rb +++ b/db/migrate/20180730213824_add_poll_translations.rb @@ -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 diff --git a/db/migrate/20180731150800_add_admin_notification_translations.rb b/db/migrate/20180731150800_add_admin_notification_translations.rb index daff4bc5d..5d5713d2a 100644 --- a/db/migrate/20180731150800_add_admin_notification_translations.rb +++ b/db/migrate/20180731150800_add_admin_notification_translations.rb @@ -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 diff --git a/db/migrate/20180731173147_add_poll_question_translations.rb b/db/migrate/20180731173147_add_poll_question_translations.rb index 6d5676c40..55955ae43 100644 --- a/db/migrate/20180731173147_add_poll_question_translations.rb +++ b/db/migrate/20180731173147_add_poll_question_translations.rb @@ -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 diff --git a/db/migrate/20180801114529_add_poll_question_answer_translations.rb b/db/migrate/20180801114529_add_poll_question_answer_translations.rb index f9ef730d5..33cff66f3 100644 --- a/db/migrate/20180801114529_add_poll_question_answer_translations.rb +++ b/db/migrate/20180801114529_add_poll_question_answer_translations.rb @@ -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 diff --git a/db/migrate/20180801140800_add_collaborative_legislation_translations.rb b/db/migrate/20180801140800_add_collaborative_legislation_translations.rb index 7dc385f77..9a30618f1 100644 --- a/db/migrate/20180801140800_add_collaborative_legislation_translations.rb +++ b/db/migrate/20180801140800_add_collaborative_legislation_translations.rb @@ -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 } - ) + t.index :legislation_process_id, name: "index_199e5fed0aca73302243f6a1fca885ce10cdbb55" + t.index :locale + end - add_column :legislation_draft_version_translations, :body_html, :text - add_column :legislation_draft_version_translations, :toc_html, :text + create_table :legislation_question_translations do |t| + t.integer :legislation_question_id, null: false + t.string :locale, null: false + t.timestamps null: false - Legislation::QuestionOption.create_translation_table!( - { value: :string }, - { migrate_data: true } - ) - end + t.text :title - def self.down - Legislation::Process.drop_translation_table! - Legislation::DraftVersion.drop_translation_table! - Legislation::Question.drop_translation_table! - Legislation::QuestionOption.drop_translation_table! + 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 diff --git a/db/migrate/20180924071722_add_translate_pages.rb b/db/migrate/20180924071722_add_translate_pages.rb index 987da6eb8..a5f5cfdce 100644 --- a/db/migrate/20180924071722_add_translate_pages.rb +++ b/db/migrate/20180924071722_add_translate_pages.rb @@ -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 - end + t.string :title + t.string :subtitle + t.text :content - def self.down - SiteCustomization::Page.drop_translation_table! - change_column :site_customization_pages, :title, :string, null: false + t.index :locale + t.index :site_customization_page_id, name: "index_7fa0f9505738cb31a31f11fb2f4c4531fed7178b" + end + + change_column_null :site_customization_pages, :title, from: false, to: true end end diff --git a/db/migrate/20181129115006_add_proposals_translations.rb b/db/migrate/20181129115006_add_proposals_translations.rb index 8f05fbffd..4348cdbc8 100644 --- a/db/migrate/20181129115006_add_proposals_translations.rb +++ b/db/migrate/20181129115006_add_proposals_translations.rb @@ -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 diff --git a/db/migrate/20181130141019_add_debates_translations.rb b/db/migrate/20181130141019_add_debates_translations.rb index 2cd1ad432..607abe3d3 100644 --- a/db/migrate/20181130141019_add_debates_translations.rb +++ b/db/migrate/20181130141019_add_debates_translations.rb @@ -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 diff --git a/db/migrate/20181205102153_add_comments_translations.rb b/db/migrate/20181205102153_add_comments_translations.rb index a7ea1b64c..c834a4bff 100644 --- a/db/migrate/20181205102153_add_comments_translations.rb +++ b/db/migrate/20181205102153_add_comments_translations.rb @@ -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 diff --git a/db/migrate/20181206153510_add_home_page_to_legislation_processes.rb b/db/migrate/20181206153510_add_home_page_to_legislation_processes.rb index 101aedbfe..741f8b424 100644 --- a/db/migrate/20181206153510_add_home_page_to_legislation_processes.rb +++ b/db/migrate/20181206153510_add_home_page_to_legislation_processes.rb @@ -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 diff --git a/db/migrate/20181214094002_add_budget_investment_translations.rb b/db/migrate/20181214094002_add_budget_investment_translations.rb index 51b9fd048..53d7f9831 100644 --- a/db/migrate/20181214094002_add_budget_investment_translations.rb +++ b/db/migrate/20181214094002_add_budget_investment_translations.rb @@ -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 } - ) + 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 + + t.string :title + t.text :description + + t.index :budget_investment_id + t.index :locale end end - - def self.down - Budget::Investment.drop_translation_table! - end end diff --git a/db/migrate/20190103132925_create_progress_bars.rb b/db/migrate/20190103132925_create_progress_bars.rb index 3ada28004..d7e026e35 100644 --- a/db/migrate/20190103132925_create_progress_bars.rb +++ b/db/migrate/20190103132925_create_progress_bars.rb @@ -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 diff --git a/db/migrate/20190104170114_add_active_polls_translations.rb b/db/migrate/20190104170114_add_active_polls_translations.rb index 51f99a0e8..ef3ff02b2 100644 --- a/db/migrate/20190104170114_add_active_polls_translations.rb +++ b/db/migrate/20190104170114_add_active_polls_translations.rb @@ -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 diff --git a/db/migrate/20190118135741_add_budget_translations.rb b/db/migrate/20190118135741_add_budget_translations.rb index a561ebb47..41d04db86 100644 --- a/db/migrate/20190118135741_add_budget_translations.rb +++ b/db/migrate/20190118135741_add_budget_translations.rb @@ -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 diff --git a/db/migrate/20190119160418_add_budget_phase_translations.rb b/db/migrate/20190119160418_add_budget_phase_translations.rb index 07bbf3c84..e3f10a8a9 100644 --- a/db/migrate/20190119160418_add_budget_phase_translations.rb +++ b/db/migrate/20190119160418_add_budget_phase_translations.rb @@ -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 diff --git a/db/migrate/20190120155819_add_budget_group_translations.rb b/db/migrate/20190120155819_add_budget_group_translations.rb index b7c2e841f..d45795192 100644 --- a/db/migrate/20190120155819_add_budget_group_translations.rb +++ b/db/migrate/20190120155819_add_budget_group_translations.rb @@ -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 diff --git a/db/migrate/20190121171237_add_budget_heading_translations.rb b/db/migrate/20190121171237_add_budget_heading_translations.rb index f6889422e..c8cf50e09 100644 --- a/db/migrate/20190121171237_add_budget_heading_translations.rb +++ b/db/migrate/20190121171237_add_budget_heading_translations.rb @@ -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