Commit a322eb1fb3309f370d3ed6bad62546ccc4b8a7d2
1 parent
979850b1
Exists in
colab
and in
4 other branches
Migrate data in addition to schema when updating project attributes
Showing
2 changed files
with
23 additions
and
11 deletions
Show diff stats
db/migrate/20151106182639_change_project_attributes_public_default.rb
1 | class ChangeProjectAttributesPublicDefault < ActiveRecord::Migration | 1 | class ChangeProjectAttributesPublicDefault < ActiveRecord::Migration |
2 | - def change | 2 | + def up |
3 | rename_column :project_attributes, :hidden, :public | 3 | rename_column :project_attributes, :hidden, :public |
4 | change_column_default :project_attributes, :public, true | 4 | change_column_default :project_attributes, :public, true |
5 | + | ||
6 | + ProjectAttributes.all.update_all('public = NOT public') | ||
7 | + end | ||
8 | + | ||
9 | + def down | ||
10 | + rename_column :project_attributes, :public, :hidden | ||
11 | + change_column_default :project_attributes, :hidden, false | ||
12 | + | ||
13 | + ProjectAttributes.all.update_all('hidden = NOT hidden') | ||
5 | end | 14 | end |
6 | end | 15 | end |
db/schema.rb
@@ -13,6 +13,9 @@ | @@ -13,6 +13,9 @@ | ||
13 | 13 | ||
14 | ActiveRecord::Schema.define(version: 20151106182639) do | 14 | ActiveRecord::Schema.define(version: 20151106182639) do |
15 | 15 | ||
16 | + # These are extensions that must be enabled in order to support this database | ||
17 | + enable_extension "plpgsql" | ||
18 | + | ||
16 | create_table "kalibro_configuration_attributes", force: :cascade do |t| | 19 | create_table "kalibro_configuration_attributes", force: :cascade do |t| |
17 | t.integer "user_id" | 20 | t.integer "user_id" |
18 | t.integer "kalibro_configuration_id" | 21 | t.integer "kalibro_configuration_id" |
@@ -45,25 +48,25 @@ ActiveRecord::Schema.define(version: 20151106182639) do | @@ -45,25 +48,25 @@ ActiveRecord::Schema.define(version: 20151106182639) do | ||
45 | t.datetime "updated_at", null: false | 48 | t.datetime "updated_at", null: false |
46 | end | 49 | end |
47 | 50 | ||
48 | - add_index "repository_attributes", ["user_id"], name: "index_repository_attributes_on_user_id" | 51 | + add_index "repository_attributes", ["user_id"], name: "index_repository_attributes_on_user_id", using: :btree |
49 | 52 | ||
50 | create_table "users", force: :cascade do |t| | 53 | create_table "users", force: :cascade do |t| |
51 | - t.string "name", default: "", null: false | ||
52 | - t.string "email", default: "", null: false | 54 | + t.string "name", limit: 255, default: "", null: false |
55 | + t.string "email", limit: 255, default: "", null: false | ||
53 | t.datetime "created_at" | 56 | t.datetime "created_at" |
54 | t.datetime "updated_at" | 57 | t.datetime "updated_at" |
55 | - t.string "encrypted_password", default: "", null: false | ||
56 | - t.string "reset_password_token" | 58 | + t.string "encrypted_password", limit: 255, default: "", null: false |
59 | + t.string "reset_password_token", limit: 255 | ||
57 | t.datetime "reset_password_sent_at" | 60 | t.datetime "reset_password_sent_at" |
58 | t.datetime "remember_created_at" | 61 | t.datetime "remember_created_at" |
59 | - t.integer "sign_in_count", default: 0 | 62 | + t.integer "sign_in_count", default: 0 |
60 | t.datetime "current_sign_in_at" | 63 | t.datetime "current_sign_in_at" |
61 | t.datetime "last_sign_in_at" | 64 | t.datetime "last_sign_in_at" |
62 | - t.string "current_sign_in_ip" | ||
63 | - t.string "last_sign_in_ip" | 65 | + t.string "current_sign_in_ip", limit: 255 |
66 | + t.string "last_sign_in_ip", limit: 255 | ||
64 | end | 67 | end |
65 | 68 | ||
66 | - add_index "users", ["email"], name: "index_users_on_email", unique: true | ||
67 | - add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true | 69 | + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree |
70 | + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree | ||
68 | 71 | ||
69 | end | 72 | end |