mirror of
https://github.com/moebooru/moebooru
synced 2025-08-22 01:47:48 +00:00
14 lines
490 B
Ruby
14 lines
490 B
Ruby
class CreatePostChangeSeq < ActiveRecord::Migration[5.1]
|
|
def self.up
|
|
execute "CREATE SEQUENCE post_change_seq INCREMENT BY 1 CACHE 10;"
|
|
execute "ALTER TABLE posts ADD COLUMN change_seq INTEGER DEFAULT nextval('post_change_seq'::regclass) NOT NULL;"
|
|
execute "ALTER SEQUENCE post_change_seq OWNED BY posts.change_seq"
|
|
add_index :posts, :change_seq
|
|
end
|
|
|
|
def self.down
|
|
remove_index :posts, :change_seq
|
|
execute "ALTER TABLE posts DROP COLUMN change_seq;"
|
|
end
|
|
end
|