2
0
mirror of https://github.com/moebooru/moebooru synced 2025-08-29 04:57:47 +00:00
moebooru/db/migrate/079_create_post_change_seq.rb

14 lines
490 B
Ruby
Raw Permalink Normal View History

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