mirror of
https://github.com/ryankazokas/turbovault-app.git
synced 2026-04-17 02:52:55 +00:00
Moving to github
This commit is contained in:
23
db/migrate/20260328183451_create_collections.rb
Normal file
23
db/migrate/20260328183451_create_collections.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
class CreateCollections < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :collections do |t|
|
||||
t.references :user, null: false, foreign_key: true, index: true
|
||||
t.string :name, null: false
|
||||
t.text :description
|
||||
t.integer :parent_collection_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :collections, :parent_collection_id
|
||||
add_foreign_key :collections, :collections, column: :parent_collection_id
|
||||
|
||||
# Enable Row Level Security
|
||||
execute <<-SQL
|
||||
ALTER TABLE collections ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
CREATE POLICY collections_isolation_policy ON collections
|
||||
USING (user_id = current_setting('app.current_user_id', true)::bigint);
|
||||
SQL
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user