2019-12-10 22:04:02 -06:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class CreateStandaloneBookmarksTable < ActiveRecord::Migration[6.0]
|
|
|
|
def up
|
|
|
|
create_table :bookmarks do |t|
|
|
|
|
t.references :user, index: true, foreign_key: true, null: false
|
|
|
|
t.references :topic, index: true, foreign_key: true, null: true
|
|
|
|
t.references :post, index: true, foreign_key: true, null: false
|
|
|
|
t.string :name, null: true
|
|
|
|
t.integer :reminder_type, null: true, index: true
|
|
|
|
t.datetime :reminder_at, null: true, index: true
|
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
2023-01-09 05:59:41 -06:00
|
|
|
add_index :bookmarks, %i[user_id post_id], unique: true
|
2019-12-10 22:04:02 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
drop_table(:bookmarks) if table_exists?(:bookmarks)
|
|
|
|
end
|
|
|
|
end
|