[deploy] Update Users, Follows, Identities, and Reaction Pks to Bigints (#9615)
This commit is contained in:
parent
52d15e79d8
commit
04fea52893
2 changed files with 79 additions and 9 deletions
|
|
@ -0,0 +1,70 @@
|
|||
class UpdateUserFollowIdentityReactionPksToBigints < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
ActiveRecord::Base.connection.execute("DROP VIEW IF EXISTS hypershield.follows")
|
||||
ActiveRecord::Base.connection.execute(
|
||||
<<-SQL
|
||||
ALTER TABLE follows
|
||||
ALTER COLUMN id TYPE bigint,
|
||||
ALTER COLUMN followable_id TYPE bigint,
|
||||
ALTER COLUMN follower_id TYPE bigint
|
||||
SQL
|
||||
)
|
||||
|
||||
ActiveRecord::Base.connection.execute("DROP VIEW IF EXISTS hypershield.identities")
|
||||
ActiveRecord::Base.connection.execute(
|
||||
<<-SQL
|
||||
ALTER TABLE identities
|
||||
ALTER COLUMN id TYPE bigint,
|
||||
ALTER COLUMN user_id TYPE bigint
|
||||
SQL
|
||||
)
|
||||
|
||||
ActiveRecord::Base.connection.execute("DROP VIEW IF EXISTS hypershield.reactions")
|
||||
ActiveRecord::Base.connection.execute(
|
||||
<<-SQL
|
||||
ALTER TABLE reactions
|
||||
ALTER COLUMN id TYPE bigint,
|
||||
ALTER COLUMN reactable_id TYPE bigint,
|
||||
ALTER COLUMN user_id TYPE bigint
|
||||
SQL
|
||||
)
|
||||
|
||||
ActiveRecord::Base.connection.execute("DROP VIEW IF EXISTS hypershield.users")
|
||||
safety_assured { change_column :users, :id, :bigint }
|
||||
end
|
||||
|
||||
def down
|
||||
ActiveRecord::Base.connection.execute("DROP VIEW IF EXISTS hypershield.follows")
|
||||
ActiveRecord::Base.connection.execute(
|
||||
<<-SQL
|
||||
ALTER TABLE follows
|
||||
ALTER COLUMN id TYPE int,
|
||||
ALTER COLUMN followable_id TYPE int,
|
||||
ALTER COLUMN follower_id TYPE int
|
||||
SQL
|
||||
)
|
||||
|
||||
ActiveRecord::Base.connection.execute("DROP VIEW IF EXISTS hypershield.identities")
|
||||
ActiveRecord::Base.connection.execute(
|
||||
<<-SQL
|
||||
ALTER TABLE identities
|
||||
ALTER COLUMN id TYPE int,
|
||||
ALTER COLUMN user_id TYPE int
|
||||
SQL
|
||||
)
|
||||
|
||||
ActiveRecord::Base.connection.execute("DROP VIEW IF EXISTS hypershield.reactions")
|
||||
ActiveRecord::Base.connection.execute(
|
||||
<<-SQL
|
||||
ALTER TABLE reactions
|
||||
ALTER COLUMN id TYPE int,
|
||||
ALTER COLUMN reactable_id TYPE int,
|
||||
ALTER COLUMN user_id TYPE int
|
||||
SQL
|
||||
)
|
||||
|
||||
ActiveRecord::Base.connection.execute("DROP VIEW IF EXISTS hypershield.users")
|
||||
safety_assured { change_column :users, :id, :int }
|
||||
end
|
||||
end
|
||||
|
||||
18
db/schema.rb
18
db/schema.rb
|
|
@ -545,12 +545,12 @@ ActiveRecord::Schema.define(version: 2020_08_05_050048) do
|
|||
t.index ["feature_key", "key", "value"], name: "index_flipper_gates_on_feature_key_and_key_and_value", unique: true
|
||||
end
|
||||
|
||||
create_table "follows", id: :serial, force: :cascade do |t|
|
||||
create_table "follows", force: :cascade do |t|
|
||||
t.boolean "blocked", default: false, null: false
|
||||
t.datetime "created_at"
|
||||
t.integer "followable_id", null: false
|
||||
t.bigint "followable_id", null: false
|
||||
t.string "followable_type", null: false
|
||||
t.integer "follower_id", null: false
|
||||
t.bigint "follower_id", null: false
|
||||
t.string "follower_type", null: false
|
||||
t.float "points", default: 1.0
|
||||
t.string "subscription_status", default: "all_articles", null: false
|
||||
|
|
@ -622,7 +622,7 @@ ActiveRecord::Schema.define(version: 2020_08_05_050048) do
|
|||
t.index ["name"], name: "index_html_variants_on_name", unique: true
|
||||
end
|
||||
|
||||
create_table "identities", id: :serial, force: :cascade do |t|
|
||||
create_table "identities", force: :cascade do |t|
|
||||
t.text "auth_data_dump"
|
||||
t.datetime "created_at", null: false
|
||||
t.string "provider"
|
||||
|
|
@ -630,7 +630,7 @@ ActiveRecord::Schema.define(version: 2020_08_05_050048) do
|
|||
t.string "token"
|
||||
t.string "uid"
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "user_id"
|
||||
t.bigint "user_id"
|
||||
t.index ["provider", "uid"], name: "index_identities_on_provider_and_uid", unique: true
|
||||
t.index ["provider", "user_id"], name: "index_identities_on_provider_and_user_id", unique: true
|
||||
end
|
||||
|
|
@ -958,15 +958,15 @@ ActiveRecord::Schema.define(version: 2020_08_05_050048) do
|
|||
t.index ["user_id"], name: "index_rating_votes_on_user_id"
|
||||
end
|
||||
|
||||
create_table "reactions", id: :serial, force: :cascade do |t|
|
||||
create_table "reactions", force: :cascade do |t|
|
||||
t.string "category"
|
||||
t.datetime "created_at", null: false
|
||||
t.float "points", default: 1.0
|
||||
t.integer "reactable_id"
|
||||
t.bigint "reactable_id"
|
||||
t.string "reactable_type"
|
||||
t.string "status", default: "valid"
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "user_id"
|
||||
t.bigint "user_id"
|
||||
t.index ["category"], name: "index_reactions_on_category"
|
||||
t.index ["created_at"], name: "index_reactions_on_created_at"
|
||||
t.index ["points"], name: "index_reactions_on_points"
|
||||
|
|
@ -1149,7 +1149,7 @@ ActiveRecord::Schema.define(version: 2020_08_05_050048) do
|
|||
t.index ["user_subscription_sourceable_type", "user_subscription_sourceable_id"], name: "index_on_user_subscription_sourcebable_type_and_id"
|
||||
end
|
||||
|
||||
create_table "users", id: :serial, force: :cascade do |t|
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.integer "articles_count", default: 0, null: false
|
||||
t.string "available_for"
|
||||
t.integer "badge_achievements_count", default: 0, null: false
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue