2
0
mirror of https://github.com/moebooru/moebooru synced 2025-08-22 01:47:48 +00:00
moebooru/db/migrate/20081203035506_add_is_held_to_posts.rb
2018-03-10 18:15:56 +09:00

14 lines
478 B
Ruby

class AddIsHeldToPosts < ActiveRecord::Migration[5.1]
def self.up
execute "ALTER TABLE posts ADD COLUMN is_held BOOLEAN NOT NULL DEFAULT FALSE"
execute "ALTER TABLE posts ADD COLUMN index_timestamp TIMESTAMP NOT NULL DEFAULT now()"
execute "UPDATE posts SET index_timestamp = created_at"
add_index :posts, :is_held
end
def self.down
execute "ALTER TABLE posts DROP COLUMN is_held"
execute "ALTER TABLE posts DROP COLUMN index_timestamp"
end
end