Files
turbovault-app/db/migrate/20260328183444_create_games.rb
2026-03-29 02:37:49 -04:00

34 lines
990 B
Ruby

class CreateGames < ActiveRecord::Migration[8.1]
def change
create_table :games do |t|
t.references :user, null: false, foreign_key: true, index: true
t.references :platform, null: false, foreign_key: true, index: true
t.string :title, null: false
t.string :format, null: false
t.date :date_added, null: false
t.string :completion_status
t.integer :user_rating
t.text :notes
t.string :condition
t.decimal :price_paid, precision: 10, scale: 2
t.string :location
t.string :digital_store
t.boolean :custom_entry, default: false, null: false
t.integer :igdb_id
t.timestamps
end
add_index :games, :title
add_index :games, :igdb_id
# Enable Row Level Security
execute <<-SQL
ALTER TABLE games ENABLE ROW LEVEL SECURITY;
CREATE POLICY games_isolation_policy ON games
USING (user_id = current_setting('app.current_user_id', true)::bigint);
SQL
end
end