Adds types

This commit is contained in:
2026-03-29 02:37:49 -04:00
parent 63276ef8ca
commit 323484a33a
44 changed files with 1273 additions and 121 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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