Moving to github

This commit is contained in:
2026-03-28 19:24:29 -04:00
commit 036fa7ab33
302 changed files with 17838 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
class CreateUsers < ActiveRecord::Migration[8.1]
def change
create_table :users do |t|
t.string :email, null: false
t.string :username, null: false
t.string :password_digest, null: false
t.text :bio
t.boolean :profile_public, default: false, null: false
t.timestamps
end
add_index :users, :email, unique: true
add_index :users, :username, unique: true
# Enable Row Level Security
enable_rls_on :users
end
private
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
end
end

View File

@@ -0,0 +1,12 @@
class CreatePlatforms < ActiveRecord::Migration[8.1]
def change
create_table :platforms do |t|
t.string :name, null: false
t.string :abbreviation
t.string :manufacturer
t.timestamps
end
add_index :platforms, :name, unique: true
end
end

View File

@@ -0,0 +1,10 @@
class CreateGenres < ActiveRecord::Migration[8.1]
def change
create_table :genres do |t|
t.string :name, null: false
t.timestamps
end
add_index :genres, :name, unique: true
end
end

View File

@@ -0,0 +1,22 @@
class CreateApiTokens < ActiveRecord::Migration[8.1]
def change
create_table :api_tokens do |t|
t.references :user, null: false, foreign_key: true, index: true
t.string :token, null: false
t.string :name
t.datetime :last_used_at
t.datetime :expires_at
t.timestamps
end
add_index :api_tokens, :token, unique: true
# 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
end
end

View 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

View File

@@ -0,0 +1,12 @@
class CreateGameGenres < ActiveRecord::Migration[8.1]
def change
create_table :game_genres do |t|
t.references :game, null: false, foreign_key: true, index: true
t.references :genre, null: false, foreign_key: true, index: true
t.timestamps
end
add_index :game_genres, [ :game_id, :genre_id ], unique: true
end
end

View 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

View File

@@ -0,0 +1,13 @@
class CreateCollectionGames < ActiveRecord::Migration[8.1]
def change
create_table :collection_games do |t|
t.references :collection, null: false, foreign_key: true, index: true
t.references :game, null: false, foreign_key: true, index: true
t.integer :position
t.timestamps
end
add_index :collection_games, [ :collection_id, :game_id ], unique: true
end
end

View 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

View File

@@ -0,0 +1,6 @@
class AddPasswordResetToUsers < ActiveRecord::Migration[8.1]
def change
add_column :users, :password_reset_token, :string
add_column :users, :password_reset_sent_at, :datetime
end
end

View File

@@ -0,0 +1,5 @@
class RenameEncryptedPasswordToPasswordDigest < ActiveRecord::Migration[8.1]
def change
rename_column :users, :encrypted_password, :password_digest
end
end

View File

@@ -0,0 +1,20 @@
class CreateIgdbGames < ActiveRecord::Migration[8.1]
def change
create_table :igdb_games do |t|
t.bigint :igdb_id, null: false
t.string :name, null: false
t.string :slug
t.string :cover_url
t.text :summary
t.date :first_release_date
t.integer :match_count, default: 0, null: false
t.datetime :last_synced_at
t.timestamps
end
add_index :igdb_games, :igdb_id, unique: true
add_index :igdb_games, :name
add_index :igdb_games, :slug
end
end

View File

@@ -0,0 +1,14 @@
class CreateIgdbPlatformMappings < ActiveRecord::Migration[8.1]
def change
create_table :igdb_platform_mappings do |t|
t.references :platform, null: false, foreign_key: true, index: true
t.integer :igdb_platform_id, null: false
t.string :igdb_platform_name
t.timestamps
end
add_index :igdb_platform_mappings, :igdb_platform_id
add_index :igdb_platform_mappings, [ :platform_id, :igdb_platform_id ], unique: true, name: 'index_platform_mappings_unique'
end
end

View File

@@ -0,0 +1,8 @@
class AddIgdbSyncToUsers < ActiveRecord::Migration[8.1]
def change
add_column :users, :igdb_sync_enabled, :boolean, default: false, null: false
add_column :users, :igdb_last_synced_at, :datetime
add_index :users, :igdb_sync_enabled
end
end

View File

@@ -0,0 +1,9 @@
class AddIgdbMatchingToGames < ActiveRecord::Migration[8.1]
def change
add_column :games, :igdb_matched_at, :datetime
add_column :games, :igdb_match_status, :string
add_column :games, :igdb_match_confidence, :decimal, precision: 5, scale: 2
add_index :games, :igdb_match_status
end
end

View File

@@ -0,0 +1,22 @@
class CreateIgdbMatchSuggestions < ActiveRecord::Migration[8.1]
def change
create_table :igdb_match_suggestions do |t|
t.references :game, null: false, foreign_key: true, index: true
t.references :igdb_game, foreign_key: true, index: true
t.bigint :igdb_id, null: false
t.string :igdb_name, null: false
t.string :igdb_slug
t.string :igdb_cover_url
t.date :igdb_release_date
t.string :igdb_platform_name
t.decimal :confidence_score, precision: 5, scale: 2
t.string :status, default: 'pending', null: false # pending, approved, rejected
t.datetime :reviewed_at
t.timestamps
end
add_index :igdb_match_suggestions, :status
add_index :igdb_match_suggestions, [ :game_id, :igdb_id ], unique: true
end
end

View File

@@ -0,0 +1,5 @@
class AddSummaryToIgdbMatchSuggestions < ActiveRecord::Migration[8.1]
def change
add_column :igdb_match_suggestions, :igdb_summary, :text
end
end

View File

@@ -0,0 +1,5 @@
class AddGenresToIgdbMatchSuggestions < ActiveRecord::Migration[8.1]
def change
add_column :igdb_match_suggestions, :igdb_genres, :text, array: true, default: []
end
end

View File

@@ -0,0 +1,5 @@
class ChangeIgdbSyncEnabledDefaultToTrue < ActiveRecord::Migration[8.1]
def change
change_column_default :users, :igdb_sync_enabled, from: false, to: true
end
end

View File

@@ -0,0 +1,6 @@
class AddThemeToUsers < ActiveRecord::Migration[8.1]
def change
add_column :users, :theme, :string, default: "light", null: false
add_index :users, :theme
end
end