mirror of
https://github.com/ryankazokas/turbovault-app.git
synced 2026-04-16 22:12:53 +00:00
Adds types
This commit is contained in:
@@ -21,7 +21,7 @@ class CreateUsers < ActiveRecord::Migration[8.1]
|
||||
def enable_rls_on(table_name)
|
||||
execute <<-SQL
|
||||
ALTER TABLE #{table_name} ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
|
||||
CREATE POLICY #{table_name}_isolation_policy ON #{table_name}
|
||||
USING (id = current_setting('app.current_user_id', true)::bigint);
|
||||
SQL
|
||||
|
||||
@@ -14,7 +14,7 @@ class CreateApiTokens < ActiveRecord::Migration[8.1]
|
||||
# Enable Row Level Security
|
||||
execute <<-SQL
|
||||
ALTER TABLE api_tokens ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
|
||||
CREATE POLICY api_tokens_isolation_policy ON api_tokens
|
||||
USING (user_id = current_setting('app.current_user_id', true)::bigint);
|
||||
SQL
|
||||
|
||||
@@ -25,7 +25,7 @@ class CreateGames < ActiveRecord::Migration[8.1]
|
||||
# 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
|
||||
|
||||
@@ -15,7 +15,7 @@ class CreateCollections < ActiveRecord::Migration[8.1]
|
||||
# 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
|
||||
|
||||
@@ -20,7 +20,7 @@ class CreateItems < ActiveRecord::Migration[8.1]
|
||||
# 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
|
||||
|
||||
14
db/seeds.rb
14
db/seeds.rb
@@ -74,7 +74,7 @@ puts "Created #{Genre.count} genres"
|
||||
# Create demo user and sample games for development
|
||||
if Rails.env.development?
|
||||
puts "Creating demo user..."
|
||||
|
||||
|
||||
demo_user = User.find_or_create_by!(email: "demo@turbovault.com") do |user|
|
||||
user.username = "demo"
|
||||
user.password = "password123"
|
||||
@@ -94,24 +94,24 @@ if Rails.env.development?
|
||||
|
||||
# Create sample collections
|
||||
puts "Creating sample collections for demo user..."
|
||||
|
||||
|
||||
nintendo_collection = demo_user.collections.find_or_create_by!(name: "Nintendo Games") do |collection|
|
||||
collection.description = "All my Nintendo platform games"
|
||||
end
|
||||
|
||||
|
||||
n64_collection = demo_user.collections.find_or_create_by!(name: "N64 Classics") do |collection|
|
||||
collection.description = "Best games from the Nintendo 64 era"
|
||||
collection.parent_collection = nintendo_collection
|
||||
end
|
||||
|
||||
|
||||
favorites_collection = demo_user.collections.find_or_create_by!(name: "All-Time Favorites") do |collection|
|
||||
collection.description = "My absolute favorite games across all platforms"
|
||||
end
|
||||
|
||||
|
||||
backlog_collection = demo_user.collections.find_or_create_by!(name: "To Play") do |collection|
|
||||
collection.description = "Games I still need to complete"
|
||||
end
|
||||
|
||||
|
||||
puts " ✓ Created #{demo_user.collections.count} collections"
|
||||
|
||||
# Only create games if demo user has none
|
||||
@@ -314,7 +314,7 @@ if Rails.env.development?
|
||||
notes: game_data[:notes],
|
||||
date_added: game_data[:date_added] || Date.current
|
||||
)
|
||||
|
||||
|
||||
game.genres = game_data[:genres] if game_data[:genres]
|
||||
game.collections = game_data[:collections] if game_data[:collections]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user