mirror of
https://github.com/ryankazokas/turbovault-app.git
synced 2026-04-17 05:32:52 +00:00
Moving to github
This commit is contained in:
28
db/migrate/20260328183500_create_items.rb
Normal file
28
db/migrate/20260328183500_create_items.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
class CreateItems < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :items do |t|
|
||||
t.references :user, null: false, foreign_key: true, index: true
|
||||
t.string :name, null: false
|
||||
t.string :item_type, null: false
|
||||
t.references :platform, foreign_key: true, index: true
|
||||
t.string :condition
|
||||
t.decimal :price_paid, precision: 10, scale: 2
|
||||
t.string :location
|
||||
t.date :date_added, null: false
|
||||
t.text :notes
|
||||
t.integer :igdb_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :items, :igdb_id
|
||||
|
||||
# Enable Row Level Security
|
||||
execute <<-SQL
|
||||
ALTER TABLE items ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
CREATE POLICY items_isolation_policy ON items
|
||||
USING (user_id = current_setting('app.current_user_id', true)::bigint);
|
||||
SQL
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user