Much base work started
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

This commit is contained in:
Dan Milne
2025-10-31 14:36:14 +11:00
parent 4a35bf6758
commit 88a906064f
97 changed files with 5333 additions and 2774 deletions

View File

@@ -0,0 +1,17 @@
class CreateWorks < ActiveRecord::Migration[8.1]
def change
create_table :works do |t|
t.string :title
t.integer :year
t.string :director
t.text :description
t.decimal :rating
t.boolean :organized
t.string :poster_path
t.string :backdrop_path
t.text :metadata
t.timestamps
end
end
end

View File

@@ -0,0 +1,11 @@
class CreateExternalIds < ActiveRecord::Migration[8.1]
def change
create_table :external_ids do |t|
t.references :work, null: false, foreign_key: true
t.integer :source
t.string :value
t.timestamps
end
end
end

View File

@@ -0,0 +1,17 @@
class CreateStorageLocations < ActiveRecord::Migration[8.1]
def change
create_table :storage_locations do |t|
t.string :name
t.string :path
t.integer :location_type
t.boolean :writable
t.boolean :enabled
t.boolean :scan_subdirectories
t.integer :priority
t.text :settings
t.datetime :last_scanned_at
t.timestamps
end
end
end

View File

@@ -0,0 +1,31 @@
class CreateVideos < ActiveRecord::Migration[8.1]
def change
create_table :videos do |t|
t.references :work, null: false, foreign_key: true
t.references :storage_location, null: false, foreign_key: true
t.string :title
t.string :file_path
t.string :file_hash
t.integer :file_size
t.float :duration
t.integer :width
t.integer :height
t.string :resolution_label
t.string :video_codec
t.string :audio_codec
t.integer :bit_rate
t.float :frame_rate
t.string :format
t.boolean :has_subtitles
t.string :version_type
t.integer :source_type
t.string :source_url
t.boolean :imported
t.boolean :processing_failed
t.text :error_message
t.text :metadata
t.timestamps
end
end
end

View File

@@ -0,0 +1,11 @@
class CreateVideoAssets < ActiveRecord::Migration[8.1]
def change
create_table :video_assets do |t|
t.references :video, null: false, foreign_key: true
t.integer :asset_type
t.text :metadata
t.timestamps
end
end
end

View File

@@ -0,0 +1,15 @@
class CreatePlaybackSessions < ActiveRecord::Migration[8.1]
def change
create_table :playback_sessions do |t|
t.references :video, null: false, foreign_key: true
t.references :user, null: false, foreign_key: true
t.float :position
t.float :duration_watched
t.datetime :last_watched_at
t.boolean :completed
t.integer :play_count
t.timestamps
end
end
end

View File

@@ -0,0 +1,11 @@
class CreateUsers < ActiveRecord::Migration[8.1]
def change
create_table :users do |t|
t.string :email_address, null: false
t.string :password_digest, null: false
t.timestamps
end
add_index :users, :email_address, unique: true
end
end

View File

@@ -0,0 +1,11 @@
class CreateSessions < ActiveRecord::Migration[8.1]
def change
create_table :sessions do |t|
t.references :user, null: false, foreign_key: true
t.string :ip_address
t.string :user_agent
t.timestamps
end
end
end

View File

@@ -0,0 +1,29 @@
class UpdateVideosFromArchitecture < ActiveRecord::Migration[8.1]
def change
change_table :videos do |t|
# Make work reference optional (videos can exist without works initially)
t.change_null :work_id, true
# Add defaults for boolean fields
t.change_default :imported, false
t.change_default :processing_failed, false
t.change_default :has_subtitles, false
# Note: file_size is already integer, SQLite compatible with bigint
# Add source_type default and make required fields not null
t.change_default :source_type, 0
t.change_null :source_type, false
# Make file_path required
t.change_null :file_path, false
end
# Add indexes as specified in architecture
add_index :videos, [:storage_location_id, :file_path], unique: true
add_index :videos, :source_type
add_index :videos, :file_hash
add_index :videos, :imported
add_index :videos, [:work_id, :resolution_label]
end
end

View File

@@ -0,0 +1,16 @@
class UpdateWorksFromArchitecture < ActiveRecord::Migration[8.1]
def change
change_table :works do |t|
# Add defaults for boolean fields
t.change_default :organized, false
# Make title required
t.change_null :title, false
end
# Add indexes as specified in architecture
add_index :works, :title
add_index :works, [:title, :year], unique: true
add_index :works, :organized
end
end

View File

@@ -0,0 +1,24 @@
class UpdateStorageLocationsFromArchitecture < ActiveRecord::Migration[8.1]
def change
change_table :storage_locations do |t|
# Add defaults for boolean fields
t.change_default :writable, false
t.change_default :enabled, true
t.change_default :scan_subdirectories, true
t.change_default :priority, 0
# Add location_type default and make required fields not null
t.change_default :location_type, 0
t.change_null :location_type, false
# Make name required
t.change_null :name, false
end
# Add indexes as specified in architecture
add_index :storage_locations, :name, unique: true
add_index :storage_locations, :location_type
add_index :storage_locations, :enabled
add_index :storage_locations, :priority
end
end

View File

@@ -0,0 +1,11 @@
class UpdateVideoAssetsFromArchitecture < ActiveRecord::Migration[8.1]
def change
change_table :video_assets do |t|
# Make asset_type required
t.change_null :asset_type, false
end
# Add indexes as specified in architecture
add_index :video_assets, [:video_id, :asset_type], unique: true
end
end

View File

@@ -0,0 +1,15 @@
class UpdatePlaybackSessionsFromArchitecture < ActiveRecord::Migration[8.1]
def change
change_table :playback_sessions do |t|
# Add defaults for fields
t.change_default :position, 0.0
t.change_default :duration_watched, 0.0
t.change_default :completed, false
t.change_default :play_count, 0
end
# Add indexes as specified in architecture
add_index :playback_sessions, [:video_id, :user_id], unique: true
add_index :playback_sessions, :last_watched_at
end
end

View File

@@ -0,0 +1,16 @@
class UpdateExternalIdsFromArchitecture < ActiveRecord::Migration[8.1]
def change
change_table :external_ids do |t|
# Make source and value required
t.change_null :source, false
t.change_null :value, false
end
# Add indexes as specified in architecture
# Ensure each source only appears once per work
add_index :external_ids, [:work_id, :source], unique: true
# Fast lookup by external ID (for "find work by IMDB ID" queries)
add_index :external_ids, [:source, :value], unique: true
end
end

View File

@@ -0,0 +1,7 @@
class AddJsonStoresToVideo < ActiveRecord::Migration[8.1]
def change
add_column :videos, :fingerprints, :text
add_column :videos, :video_metadata, :text
add_column :videos, :processing_info, :text
end
end

View File

@@ -0,0 +1,7 @@
class AddJsonStoresToWork < ActiveRecord::Migration[8.1]
def change
add_column :works, :tmdb_data, :text
add_column :works, :imdb_data, :text
add_column :works, :custom_fields, :text
end
end

View File

@@ -0,0 +1,8 @@
class AddPhase1FieldsToVideos < ActiveRecord::Migration[8.1]
def change
add_column :videos, :filename, :string
add_column :videos, :transcoded_path, :string
add_column :videos, :transcoded_permanently, :boolean
add_column :videos, :web_compatible, :boolean
end
end

View File

@@ -0,0 +1,5 @@
class AddProcessedToVideos < ActiveRecord::Migration[8.1]
def change
add_column :videos, :processed, :boolean
end
end

View File

@@ -0,0 +1,6 @@
class AddTypeToVideos < ActiveRecord::Migration[8.1]
def change
add_column :videos, :type, :string, default: 'Video', null: false
add_index :videos, :type
end
end