Aggiunge modulo Replay, Garage dev e YouTube a livello società.
Pipeline registrazione/upload con storage S3, archivio web e app, proxy replay per il browser, OAuth YouTube sulla pagina club (Premium Full) e footer legale. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
class EnhanceRecordingsForReplayModule < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
change_table :recordings, bulk: true do |t|
|
||||
t.string :title
|
||||
t.string :privacy_status, null: false, default: "unlisted"
|
||||
t.bigint :byte_size
|
||||
t.integer :duration_secs
|
||||
t.string :storage_key
|
||||
t.string :storage_bucket
|
||||
t.string :storage_backend, null: false, default: "local"
|
||||
t.datetime :recorded_at
|
||||
t.datetime :deleted_at
|
||||
t.text :error_message
|
||||
end
|
||||
|
||||
add_index :recordings, :privacy_status
|
||||
add_index :recordings, :deleted_at
|
||||
add_index :recordings, %i[team_id status]
|
||||
add_index :recordings, :storage_key, unique: true, where: "storage_key IS NOT NULL"
|
||||
end
|
||||
end
|
||||
16
backend/db/migrate/20260528140000_replay_enhancements.rb
Normal file
16
backend/db/migrate/20260528140000_replay_enhancements.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class ReplayEnhancements < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
change_table :recordings, bulk: true do |t|
|
||||
t.jsonb :metadata, null: false, default: {}
|
||||
t.string :thumbnail_storage_key
|
||||
t.integer :view_count, null: false, default: 0
|
||||
t.datetime :ready_notified_at
|
||||
t.datetime :expiry_warning_sent_at
|
||||
t.string :youtube_video_id
|
||||
t.datetime :youtube_published_at
|
||||
end
|
||||
|
||||
add_index :recordings, :view_count
|
||||
add_index :recordings, :youtube_video_id, where: "youtube_video_id IS NOT NULL"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,57 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MoveYoutubeCredentialsToClubs < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
unless column_exists?(:youtube_credentials, :club_id)
|
||||
add_reference :youtube_credentials, :club, type: :uuid, foreign_key: true
|
||||
end
|
||||
|
||||
if column_exists?(:youtube_credentials, :team_id)
|
||||
say_with_time "Associa credenziali YouTube alle società" do
|
||||
execute <<~SQL.squish
|
||||
UPDATE youtube_credentials yc
|
||||
SET club_id = t.club_id
|
||||
FROM teams t
|
||||
WHERE t.id = yc.team_id AND yc.club_id IS NULL
|
||||
SQL
|
||||
end
|
||||
|
||||
execute <<~SQL.squish
|
||||
DELETE FROM youtube_credentials yc
|
||||
USING youtube_credentials newer
|
||||
WHERE yc.club_id = newer.club_id
|
||||
AND yc.id <> newer.id
|
||||
AND yc.updated_at < newer.updated_at
|
||||
SQL
|
||||
|
||||
change_column_null :youtube_credentials, :club_id, false
|
||||
remove_index :youtube_credentials, :team_id, if_exists: true
|
||||
remove_reference :youtube_credentials, :team, foreign_key: true
|
||||
end
|
||||
|
||||
unless index_exists?(:youtube_credentials, :club_id)
|
||||
add_index :youtube_credentials, :club_id, unique: true
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
return unless column_exists?(:youtube_credentials, :club_id)
|
||||
|
||||
add_reference :youtube_credentials, :team, type: :uuid, foreign_key: true unless column_exists?(:youtube_credentials, :team_id)
|
||||
|
||||
execute <<~SQL.squish
|
||||
UPDATE youtube_credentials yc
|
||||
SET team_id = (
|
||||
SELECT t.id FROM teams t
|
||||
WHERE t.club_id = yc.club_id
|
||||
ORDER BY t.created_at
|
||||
LIMIT 1
|
||||
)
|
||||
SQL
|
||||
|
||||
change_column_null :youtube_credentials, :team_id, false
|
||||
remove_index :youtube_credentials, :club_id, if_exists: true
|
||||
remove_reference :youtube_credentials, :club, foreign_key: true
|
||||
add_index :youtube_credentials, :team_id, if_not_exists: true
|
||||
end
|
||||
end
|
||||
31
backend/db/schema.rb
generated
31
backend/db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2026_06_03_120000) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2026_06_03_121000) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
@@ -176,9 +176,32 @@ ActiveRecord::Schema[7.2].define(version: 2026_06_03_120000) do
|
||||
t.datetime "expires_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "title"
|
||||
t.string "privacy_status", default: "unlisted", null: false
|
||||
t.bigint "byte_size"
|
||||
t.integer "duration_secs"
|
||||
t.string "storage_key"
|
||||
t.string "storage_bucket"
|
||||
t.string "storage_backend", default: "local", null: false
|
||||
t.datetime "recorded_at"
|
||||
t.datetime "deleted_at"
|
||||
t.text "error_message"
|
||||
t.jsonb "metadata", default: {}, null: false
|
||||
t.string "thumbnail_storage_key"
|
||||
t.integer "view_count", default: 0, null: false
|
||||
t.datetime "ready_notified_at"
|
||||
t.datetime "expiry_warning_sent_at"
|
||||
t.string "youtube_video_id"
|
||||
t.datetime "youtube_published_at"
|
||||
t.index ["deleted_at"], name: "index_recordings_on_deleted_at"
|
||||
t.index ["expires_at"], name: "index_recordings_on_expires_at"
|
||||
t.index ["privacy_status"], name: "index_recordings_on_privacy_status"
|
||||
t.index ["storage_key"], name: "index_recordings_on_storage_key", unique: true, where: "(storage_key IS NOT NULL)"
|
||||
t.index ["stream_session_id"], name: "index_recordings_on_stream_session_id", unique: true
|
||||
t.index ["team_id", "status"], name: "index_recordings_on_team_id_and_status"
|
||||
t.index ["team_id"], name: "index_recordings_on_team_id"
|
||||
t.index ["view_count"], name: "index_recordings_on_view_count"
|
||||
t.index ["youtube_video_id"], name: "index_recordings_on_youtube_video_id", where: "(youtube_video_id IS NOT NULL)"
|
||||
end
|
||||
|
||||
create_table "score_states", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
@@ -334,7 +357,6 @@ ActiveRecord::Schema[7.2].define(version: 2026_06_03_120000) do
|
||||
end
|
||||
|
||||
create_table "youtube_credentials", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "team_id", null: false
|
||||
t.text "access_token_encrypted"
|
||||
t.text "refresh_token_encrypted"
|
||||
t.datetime "expires_at"
|
||||
@@ -342,7 +364,8 @@ ActiveRecord::Schema[7.2].define(version: 2026_06_03_120000) do
|
||||
t.string "channel_title"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["team_id"], name: "index_youtube_credentials_on_team_id"
|
||||
t.uuid "club_id", null: false
|
||||
t.index ["club_id"], name: "index_youtube_credentials_on_club_id"
|
||||
end
|
||||
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
@@ -369,5 +392,5 @@ ActiveRecord::Schema[7.2].define(version: 2026_06_03_120000) do
|
||||
add_foreign_key "teams", "clubs"
|
||||
add_foreign_key "user_teams", "teams"
|
||||
add_foreign_key "user_teams", "users"
|
||||
add_foreign_key "youtube_credentials", "teams"
|
||||
add_foreign_key "youtube_credentials", "clubs"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user