mirror of
https://github.com/ryankazokas/turbovault-app.git
synced 2026-04-16 23:22:53 +00:00
Moving to github
This commit is contained in:
33
db/migrate/20260328183444_create_games.rb
Normal file
33
db/migrate/20260328183444_create_games.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
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
|
||||
Reference in New Issue
Block a user