Skip to content

Commit

Permalink
Merge pull request #422 from PecanProject/add-missing-id
Browse files Browse the repository at this point in the history
missing id for columns #403
  • Loading branch information
gsrohde committed Jun 17, 2016
2 parents 6d36144 + 9b89dee commit f5886e6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions db/migrate/20160617133217_add_id_to_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class AddIdToTable < ActiveRecord::Migration
def up
this_hostid = Machine.new.hostid

execute %{
ALTER TABLE "cultivars_pfts" ADD "id" bigserial;
SELECT setval('cultivars_pfts_id_seq', GREATEST(1, CAST(1e9 * #{this_hostid}::int AS bigint)), FALSE);
ALTER TABLE "trait_covariate_associations" ADD "id" bigserial;
SELECT setval('trait_covariate_associations_id_seq', GREATEST(1, CAST(1e9 * #{this_hostid}::int AS bigint)), FALSE);
}
end

def down
remove_column :cultivars_pfts, :id
remove_column :trait_covariate_associations, :id
end
end

0 comments on commit f5886e6

Please sign in to comment.