Skip to content

Commit

Permalink
Fixed backward compatibility and duplicate indexes in migration files
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikola Trandafilovic committed Nov 8, 2011
1 parent 99583fe commit 7de48cf
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.up
t.integer :updated_by
t.timestamps
end
add_index :weekly_sale_setup_liquids, [:name, :weekly_sale_setup_id], :unique => true
add_index :weekly_sale_setup_liquids, [:name, :weekly_sale_setup_id], :unique => true, :name => "weekly_sale_setup_liqs"
execute "ALTER TABLE weekly_sale_setup_liquids ADD CONSTRAINT fk_weekly_sale_setup_liquids_account FOREIGN KEY (account_id) REFERENCES accounts(id) "
execute "ALTER TABLE weekly_sale_setup_liquids ADD CONSTRAINT fk_weekly_sale_setup_liquids_wueekly_sale_setup FOREIGN KEY (weekly_sale_setup_id) REFERENCES weekly_sale_setups(id) "
execute "ALTER TABLE weekly_sale_setup_liquids ADD CONSTRAINT fk_weekly_sale_setup_liquids_created_by FOREIGN KEY (created_by) REFERENCES users(id) "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.up

t.timestamps
end
add_index :weekly_sale_setup_product_groups, [:name, :weekly_sale_setup_id], :unique => true
add_index :weekly_sale_setup_product_groups, [:name, :weekly_sale_setup_id], :unique => true , :name => "weekly_sale_setup_prod_groups"
execute "ALTER TABLE weekly_sale_setup_product_groups ADD CONSTRAINT fk_weekly_sale_setup_product_groups_project FOREIGN KEY (project_id) REFERENCES projects(id) "
execute "ALTER TABLE weekly_sale_setup_product_groups ADD CONSTRAINT fk_weekly_sale_setup_product_groups_account FOREIGN KEY (account_id) REFERENCES accounts(id) "
execute "ALTER TABLE weekly_sale_setup_product_groups ADD CONSTRAINT fk_weekly_sale_setup_product_groups_wueekly_sale_setup FOREIGN KEY (weekly_sale_setup_id) REFERENCES weekly_sale_setups(id) "
Expand Down
2 changes: 0 additions & 2 deletions db/migrate/20101104220037_add_indexes_to_journals.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
class AddIndexesToJournals < ActiveRecord::Migration
def self.up
add_index :journals, :company_id
add_index :journals, :bill_id
add_index :journals, :period_id
add_index :journals, :journal_type_id
end

def self.down
remove_index :journals, :company_id
remove_index :journals, :bill_id
remove_index :journals, :period_id
remove_index :journals, :journal_type_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
class AddIndexesToJournalOperations < ActiveRecord::Migration
def self.up
add_index :journal_operations, :journal_id
add_index :journal_operations, :account_id
add_index :journal_operations, :vat_account_id
add_index :journal_operations, :project_id
add_index :journal_operations, :ledger_id
end

def self.down
remove_index :journal_operations, :journal_id
remove_index :journal_operations, :account_id
remove_index :journal_operations, :vat_account_id
remove_index :journal_operations, :project_id
Expand Down

0 comments on commit 7de48cf

Please sign in to comment.