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

Use references to define polymorphic associations in generator migrations #292

Merged
merged 1 commit into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ class CreateStringTranslations < <%= activerecord_migration_class %>

def change
create_table :mobility_string_translations do |t|
t.string :locale, null: false
t.string :key, null: false
t.string :value
t.integer :translatable_id, null: false
t.string :translatable_type, null: false
t.timestamps null: false
t.string :locale, null: false
t.string :key, null: false
t.string :value
t.references :translatable, polymorphic: true, index: false
t.timestamps null: false
end
add_index :mobility_string_translations, [:translatable_id, :translatable_type, :locale, :key], unique: true, name: :index_mobility_string_translations_on_keys
add_index :mobility_string_translations, [:translatable_id, :translatable_type, :key], name: :index_mobility_string_translations_on_translatable_attribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ class CreateTextTranslations < <%= activerecord_migration_class %>

def change
create_table :mobility_text_translations do |t|
t.string :locale, null: false
t.string :key, null: false
t.text :value
t.integer :translatable_id, null: false
t.string :translatable_type, null: false
t.timestamps null: false
t.string :locale, null: false
t.string :key, null: false
t.text :value
t.references :translatable, polymorphic: true, index: false
t.timestamps null: false
end
add_index :mobility_text_translations, [:translatable_id, :translatable_type, :locale, :key], unique: true, name: :index_mobility_text_translations_on_keys
add_index :mobility_text_translations, [:translatable_id, :translatable_type, :key], name: :index_mobility_text_translations_on_translatable_attribute
Expand Down
6 changes: 4 additions & 2 deletions spec/generators/rails/mobility/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
end
contains "def change"
contains "create_table :mobility_text_translations"
contains "t.text :value"
contains "t.text :value"
contains "t.references :translatable, polymorphic: true, index: false"
contains "add_index :mobility_text_translations"
contains "name: :index_mobility_text_translations_on_keys"
contains "name: :index_mobility_text_translations_on_translatable_attribute"
Expand All @@ -68,7 +69,8 @@
end
contains "def change"
contains "create_table :mobility_string_translations"
contains "t.string :value"
contains "t.string :value"
contains "t.references :translatable, polymorphic: true, index: false"
contains "add_index :mobility_string_translations"
contains "name: :index_mobility_string_translations_on_keys"
contains "name: :index_mobility_string_translations_on_translatable_attribute"
Expand Down