1 class AddChangesets < ActiveRecord::Migration
2 @@conv_user_tables = ['current_nodes',
3 'current_relations', 'current_ways', 'nodes', 'relations', 'ways' ]
6 create_table "changesets", innodb_table do |t|
7 t.column "id", :bigint, :limit => 20, :null => false
8 t.column "user_id", :bigint, :limit => 20, :null => false
9 t.column "created_at", :datetime, :null => false
10 t.column "open", :boolean, :null => false, :default => true
11 t.column "min_lat", :integer, :null => true
12 t.column "max_lat", :integer, :null => true
13 t.column "min_lon", :integer, :null => true
14 t.column "max_lon", :integer, :null => true
17 add_primary_key "changesets", ["id"]
20 change_column "changesets", "id", :bigint, :limit => 20, :null => false, :options => "AUTO_INCREMENT"
22 create_table "changeset_tags", innodb_table do |t|
23 t.column "id", :bigint, :limit => 64, :null => false
24 t.column "k", :string, :default => "", :null => false
25 t.column "v", :string, :default => "", :null => false
28 add_index "changeset_tags", ["id"], :name => "changeset_tags_id_idx"
31 # Initially we will have one changeset for every user containing
32 # all edits up to the API change,
33 # all the changesets will have the id of the user that made them.
34 # We need to generate a changeset for each user in the database
35 execute "INSERT INTO changesets (id, user_id, created_at, open)" +
36 "SELECT id, id, creation_time, 0 from users;"
38 @@conv_user_tables.each { |tbl|
39 rename_column tbl, :user_id, :changeset_id
41 add_foreign_key tbl, [:changeset_id], :users
46 # It's not easy to generate the user ids from the changesets
47 raise IrreversibleMigration.new
48 #drop_table "changesets"
49 #drop_table "changeset_tags"