Remove S3 bucket columns from media_sets table
continuous-integration/drone/push Build is passing Details

Re: #5
This commit is contained in:
Rob Watson 2021-12-13 04:28:14 +01:00
parent 37a74e218f
commit c8de6643e8
8 changed files with 47 additions and 85 deletions

View File

@ -17,17 +17,14 @@ type MediaSet struct {
AudioFramesApprox int64 AudioFramesApprox int64
AudioFrames sql.NullInt64 AudioFrames sql.NullInt64
AudioSampleRate int32 AudioSampleRate int32
AudioRawS3Bucket sql.NullString
AudioRawS3Key sql.NullString AudioRawS3Key sql.NullString
AudioRawS3UploadedAt sql.NullTime AudioRawS3UploadedAt sql.NullTime
AudioEncodedMimeType string AudioEncodedMimeType string
VideoYoutubeItag int32 VideoYoutubeItag int32
VideoS3Bucket sql.NullString
VideoS3Key sql.NullString VideoS3Key sql.NullString
VideoS3UploadedAt sql.NullTime VideoS3UploadedAt sql.NullTime
VideoMimeType string VideoMimeType string
VideoDurationNanos int64 VideoDurationNanos int64
VideoThumbnailS3Bucket sql.NullString
VideoThumbnailS3Key sql.NullString VideoThumbnailS3Key sql.NullString
VideoThumbnailS3UploadedAt sql.NullTime VideoThumbnailS3UploadedAt sql.NullTime
VideoThumbnailMimeType sql.NullString VideoThumbnailMimeType sql.NullString
@ -37,7 +34,6 @@ type MediaSet struct {
UpdatedAt time.Time UpdatedAt time.Time
AudioContentLength int64 AudioContentLength int64
VideoContentLength int64 VideoContentLength int64
AudioEncodedS3Bucket sql.NullString
AudioEncodedS3Key sql.NullString AudioEncodedS3Key sql.NullString
AudioEncodedS3UploadedAt sql.NullTime AudioEncodedS3UploadedAt sql.NullTime
} }

View File

@ -13,7 +13,7 @@ import (
const createMediaSet = `-- name: CreateMediaSet :one const createMediaSet = `-- name: CreateMediaSet :one
INSERT INTO media_sets (youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_sample_rate, audio_content_length, audio_encoded_mime_type, video_youtube_itag, video_content_length, video_mime_type, video_duration_nanos, created_at, updated_at) INSERT INTO media_sets (youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_sample_rate, audio_content_length, audio_encoded_mime_type, video_youtube_itag, video_content_length, video_mime_type, video_duration_nanos, created_at, updated_at)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, NOW(), NOW()) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, NOW(), NOW())
RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_bucket, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_bucket, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_bucket, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_bucket, audio_encoded_s3_key, audio_encoded_s3_uploaded_at RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at
` `
type CreateMediaSetParams struct { type CreateMediaSetParams struct {
@ -53,17 +53,14 @@ func (q *Queries) CreateMediaSet(ctx context.Context, arg CreateMediaSetParams)
&i.AudioFramesApprox, &i.AudioFramesApprox,
&i.AudioFrames, &i.AudioFrames,
&i.AudioSampleRate, &i.AudioSampleRate,
&i.AudioRawS3Bucket,
&i.AudioRawS3Key, &i.AudioRawS3Key,
&i.AudioRawS3UploadedAt, &i.AudioRawS3UploadedAt,
&i.AudioEncodedMimeType, &i.AudioEncodedMimeType,
&i.VideoYoutubeItag, &i.VideoYoutubeItag,
&i.VideoS3Bucket,
&i.VideoS3Key, &i.VideoS3Key,
&i.VideoS3UploadedAt, &i.VideoS3UploadedAt,
&i.VideoMimeType, &i.VideoMimeType,
&i.VideoDurationNanos, &i.VideoDurationNanos,
&i.VideoThumbnailS3Bucket,
&i.VideoThumbnailS3Key, &i.VideoThumbnailS3Key,
&i.VideoThumbnailS3UploadedAt, &i.VideoThumbnailS3UploadedAt,
&i.VideoThumbnailMimeType, &i.VideoThumbnailMimeType,
@ -73,7 +70,6 @@ func (q *Queries) CreateMediaSet(ctx context.Context, arg CreateMediaSetParams)
&i.UpdatedAt, &i.UpdatedAt,
&i.AudioContentLength, &i.AudioContentLength,
&i.VideoContentLength, &i.VideoContentLength,
&i.AudioEncodedS3Bucket,
&i.AudioEncodedS3Key, &i.AudioEncodedS3Key,
&i.AudioEncodedS3UploadedAt, &i.AudioEncodedS3UploadedAt,
) )
@ -81,7 +77,7 @@ func (q *Queries) CreateMediaSet(ctx context.Context, arg CreateMediaSetParams)
} }
const getMediaSet = `-- name: GetMediaSet :one const getMediaSet = `-- name: GetMediaSet :one
SELECT id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_bucket, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_bucket, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_bucket, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_bucket, audio_encoded_s3_key, audio_encoded_s3_uploaded_at FROM media_sets WHERE id = $1 SELECT id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at FROM media_sets WHERE id = $1
` `
func (q *Queries) GetMediaSet(ctx context.Context, id uuid.UUID) (MediaSet, error) { func (q *Queries) GetMediaSet(ctx context.Context, id uuid.UUID) (MediaSet, error) {
@ -95,17 +91,14 @@ func (q *Queries) GetMediaSet(ctx context.Context, id uuid.UUID) (MediaSet, erro
&i.AudioFramesApprox, &i.AudioFramesApprox,
&i.AudioFrames, &i.AudioFrames,
&i.AudioSampleRate, &i.AudioSampleRate,
&i.AudioRawS3Bucket,
&i.AudioRawS3Key, &i.AudioRawS3Key,
&i.AudioRawS3UploadedAt, &i.AudioRawS3UploadedAt,
&i.AudioEncodedMimeType, &i.AudioEncodedMimeType,
&i.VideoYoutubeItag, &i.VideoYoutubeItag,
&i.VideoS3Bucket,
&i.VideoS3Key, &i.VideoS3Key,
&i.VideoS3UploadedAt, &i.VideoS3UploadedAt,
&i.VideoMimeType, &i.VideoMimeType,
&i.VideoDurationNanos, &i.VideoDurationNanos,
&i.VideoThumbnailS3Bucket,
&i.VideoThumbnailS3Key, &i.VideoThumbnailS3Key,
&i.VideoThumbnailS3UploadedAt, &i.VideoThumbnailS3UploadedAt,
&i.VideoThumbnailMimeType, &i.VideoThumbnailMimeType,
@ -115,7 +108,6 @@ func (q *Queries) GetMediaSet(ctx context.Context, id uuid.UUID) (MediaSet, erro
&i.UpdatedAt, &i.UpdatedAt,
&i.AudioContentLength, &i.AudioContentLength,
&i.VideoContentLength, &i.VideoContentLength,
&i.AudioEncodedS3Bucket,
&i.AudioEncodedS3Key, &i.AudioEncodedS3Key,
&i.AudioEncodedS3UploadedAt, &i.AudioEncodedS3UploadedAt,
) )
@ -123,7 +115,7 @@ func (q *Queries) GetMediaSet(ctx context.Context, id uuid.UUID) (MediaSet, erro
} }
const getMediaSetByYoutubeID = `-- name: GetMediaSetByYoutubeID :one const getMediaSetByYoutubeID = `-- name: GetMediaSetByYoutubeID :one
SELECT id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_bucket, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_bucket, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_bucket, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_bucket, audio_encoded_s3_key, audio_encoded_s3_uploaded_at FROM media_sets WHERE youtube_id = $1 SELECT id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at FROM media_sets WHERE youtube_id = $1
` `
func (q *Queries) GetMediaSetByYoutubeID(ctx context.Context, youtubeID string) (MediaSet, error) { func (q *Queries) GetMediaSetByYoutubeID(ctx context.Context, youtubeID string) (MediaSet, error) {
@ -137,17 +129,14 @@ func (q *Queries) GetMediaSetByYoutubeID(ctx context.Context, youtubeID string)
&i.AudioFramesApprox, &i.AudioFramesApprox,
&i.AudioFrames, &i.AudioFrames,
&i.AudioSampleRate, &i.AudioSampleRate,
&i.AudioRawS3Bucket,
&i.AudioRawS3Key, &i.AudioRawS3Key,
&i.AudioRawS3UploadedAt, &i.AudioRawS3UploadedAt,
&i.AudioEncodedMimeType, &i.AudioEncodedMimeType,
&i.VideoYoutubeItag, &i.VideoYoutubeItag,
&i.VideoS3Bucket,
&i.VideoS3Key, &i.VideoS3Key,
&i.VideoS3UploadedAt, &i.VideoS3UploadedAt,
&i.VideoMimeType, &i.VideoMimeType,
&i.VideoDurationNanos, &i.VideoDurationNanos,
&i.VideoThumbnailS3Bucket,
&i.VideoThumbnailS3Key, &i.VideoThumbnailS3Key,
&i.VideoThumbnailS3UploadedAt, &i.VideoThumbnailS3UploadedAt,
&i.VideoThumbnailMimeType, &i.VideoThumbnailMimeType,
@ -157,7 +146,6 @@ func (q *Queries) GetMediaSetByYoutubeID(ctx context.Context, youtubeID string)
&i.UpdatedAt, &i.UpdatedAt,
&i.AudioContentLength, &i.AudioContentLength,
&i.VideoContentLength, &i.VideoContentLength,
&i.AudioEncodedS3Bucket,
&i.AudioEncodedS3Key, &i.AudioEncodedS3Key,
&i.AudioEncodedS3UploadedAt, &i.AudioEncodedS3UploadedAt,
) )
@ -166,19 +154,18 @@ func (q *Queries) GetMediaSetByYoutubeID(ctx context.Context, youtubeID string)
const setEncodedAudioUploaded = `-- name: SetEncodedAudioUploaded :one const setEncodedAudioUploaded = `-- name: SetEncodedAudioUploaded :one
UPDATE media_sets UPDATE media_sets
SET audio_encoded_s3_bucket = $2, audio_encoded_s3_key = $3, audio_encoded_s3_uploaded_at = NOW(), updated_at = NOW() SET audio_encoded_s3_key = $2, audio_encoded_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1 WHERE id = $1
RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_bucket, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_bucket, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_bucket, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_bucket, audio_encoded_s3_key, audio_encoded_s3_uploaded_at RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at
` `
type SetEncodedAudioUploadedParams struct { type SetEncodedAudioUploadedParams struct {
ID uuid.UUID ID uuid.UUID
AudioEncodedS3Bucket sql.NullString
AudioEncodedS3Key sql.NullString AudioEncodedS3Key sql.NullString
} }
func (q *Queries) SetEncodedAudioUploaded(ctx context.Context, arg SetEncodedAudioUploadedParams) (MediaSet, error) { func (q *Queries) SetEncodedAudioUploaded(ctx context.Context, arg SetEncodedAudioUploadedParams) (MediaSet, error) {
row := q.db.QueryRow(ctx, setEncodedAudioUploaded, arg.ID, arg.AudioEncodedS3Bucket, arg.AudioEncodedS3Key) row := q.db.QueryRow(ctx, setEncodedAudioUploaded, arg.ID, arg.AudioEncodedS3Key)
var i MediaSet var i MediaSet
err := row.Scan( err := row.Scan(
&i.ID, &i.ID,
@ -188,17 +175,14 @@ func (q *Queries) SetEncodedAudioUploaded(ctx context.Context, arg SetEncodedAud
&i.AudioFramesApprox, &i.AudioFramesApprox,
&i.AudioFrames, &i.AudioFrames,
&i.AudioSampleRate, &i.AudioSampleRate,
&i.AudioRawS3Bucket,
&i.AudioRawS3Key, &i.AudioRawS3Key,
&i.AudioRawS3UploadedAt, &i.AudioRawS3UploadedAt,
&i.AudioEncodedMimeType, &i.AudioEncodedMimeType,
&i.VideoYoutubeItag, &i.VideoYoutubeItag,
&i.VideoS3Bucket,
&i.VideoS3Key, &i.VideoS3Key,
&i.VideoS3UploadedAt, &i.VideoS3UploadedAt,
&i.VideoMimeType, &i.VideoMimeType,
&i.VideoDurationNanos, &i.VideoDurationNanos,
&i.VideoThumbnailS3Bucket,
&i.VideoThumbnailS3Key, &i.VideoThumbnailS3Key,
&i.VideoThumbnailS3UploadedAt, &i.VideoThumbnailS3UploadedAt,
&i.VideoThumbnailMimeType, &i.VideoThumbnailMimeType,
@ -208,7 +192,6 @@ func (q *Queries) SetEncodedAudioUploaded(ctx context.Context, arg SetEncodedAud
&i.UpdatedAt, &i.UpdatedAt,
&i.AudioContentLength, &i.AudioContentLength,
&i.VideoContentLength, &i.VideoContentLength,
&i.AudioEncodedS3Bucket,
&i.AudioEncodedS3Key, &i.AudioEncodedS3Key,
&i.AudioEncodedS3UploadedAt, &i.AudioEncodedS3UploadedAt,
) )
@ -217,25 +200,19 @@ func (q *Queries) SetEncodedAudioUploaded(ctx context.Context, arg SetEncodedAud
const setRawAudioUploaded = `-- name: SetRawAudioUploaded :one const setRawAudioUploaded = `-- name: SetRawAudioUploaded :one
UPDATE media_sets UPDATE media_sets
SET audio_raw_s3_bucket = $2, audio_raw_s3_key = $3, audio_frames = $4, audio_raw_s3_uploaded_at = NOW(), updated_at = NOW() SET audio_raw_s3_key = $2, audio_frames = $3, audio_raw_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1 WHERE id = $1
RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_bucket, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_bucket, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_bucket, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_bucket, audio_encoded_s3_key, audio_encoded_s3_uploaded_at RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at
` `
type SetRawAudioUploadedParams struct { type SetRawAudioUploadedParams struct {
ID uuid.UUID ID uuid.UUID
AudioRawS3Bucket sql.NullString
AudioRawS3Key sql.NullString AudioRawS3Key sql.NullString
AudioFrames sql.NullInt64 AudioFrames sql.NullInt64
} }
func (q *Queries) SetRawAudioUploaded(ctx context.Context, arg SetRawAudioUploadedParams) (MediaSet, error) { func (q *Queries) SetRawAudioUploaded(ctx context.Context, arg SetRawAudioUploadedParams) (MediaSet, error) {
row := q.db.QueryRow(ctx, setRawAudioUploaded, row := q.db.QueryRow(ctx, setRawAudioUploaded, arg.ID, arg.AudioRawS3Key, arg.AudioFrames)
arg.ID,
arg.AudioRawS3Bucket,
arg.AudioRawS3Key,
arg.AudioFrames,
)
var i MediaSet var i MediaSet
err := row.Scan( err := row.Scan(
&i.ID, &i.ID,
@ -245,17 +222,14 @@ func (q *Queries) SetRawAudioUploaded(ctx context.Context, arg SetRawAudioUpload
&i.AudioFramesApprox, &i.AudioFramesApprox,
&i.AudioFrames, &i.AudioFrames,
&i.AudioSampleRate, &i.AudioSampleRate,
&i.AudioRawS3Bucket,
&i.AudioRawS3Key, &i.AudioRawS3Key,
&i.AudioRawS3UploadedAt, &i.AudioRawS3UploadedAt,
&i.AudioEncodedMimeType, &i.AudioEncodedMimeType,
&i.VideoYoutubeItag, &i.VideoYoutubeItag,
&i.VideoS3Bucket,
&i.VideoS3Key, &i.VideoS3Key,
&i.VideoS3UploadedAt, &i.VideoS3UploadedAt,
&i.VideoMimeType, &i.VideoMimeType,
&i.VideoDurationNanos, &i.VideoDurationNanos,
&i.VideoThumbnailS3Bucket,
&i.VideoThumbnailS3Key, &i.VideoThumbnailS3Key,
&i.VideoThumbnailS3UploadedAt, &i.VideoThumbnailS3UploadedAt,
&i.VideoThumbnailMimeType, &i.VideoThumbnailMimeType,
@ -265,7 +239,6 @@ func (q *Queries) SetRawAudioUploaded(ctx context.Context, arg SetRawAudioUpload
&i.UpdatedAt, &i.UpdatedAt,
&i.AudioContentLength, &i.AudioContentLength,
&i.VideoContentLength, &i.VideoContentLength,
&i.AudioEncodedS3Bucket,
&i.AudioEncodedS3Key, &i.AudioEncodedS3Key,
&i.AudioEncodedS3UploadedAt, &i.AudioEncodedS3UploadedAt,
) )
@ -274,9 +247,9 @@ func (q *Queries) SetRawAudioUploaded(ctx context.Context, arg SetRawAudioUpload
const setVideoThumbnailUploaded = `-- name: SetVideoThumbnailUploaded :one const setVideoThumbnailUploaded = `-- name: SetVideoThumbnailUploaded :one
UPDATE media_sets UPDATE media_sets
SET video_thumbnail_width = $2, video_thumbnail_height = $3, video_thumbnail_mime_type = $4, video_thumbnail_s3_bucket = $5, video_thumbnail_s3_key = $6, video_thumbnail_s3_uploaded_at = NOW(), updated_at = NOW() SET video_thumbnail_width = $2, video_thumbnail_height = $3, video_thumbnail_mime_type = $4, video_thumbnail_s3_key = $5, video_thumbnail_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1 WHERE id = $1
RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_bucket, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_bucket, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_bucket, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_bucket, audio_encoded_s3_key, audio_encoded_s3_uploaded_at RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at
` `
type SetVideoThumbnailUploadedParams struct { type SetVideoThumbnailUploadedParams struct {
@ -284,7 +257,6 @@ type SetVideoThumbnailUploadedParams struct {
VideoThumbnailWidth sql.NullInt32 VideoThumbnailWidth sql.NullInt32
VideoThumbnailHeight sql.NullInt32 VideoThumbnailHeight sql.NullInt32
VideoThumbnailMimeType sql.NullString VideoThumbnailMimeType sql.NullString
VideoThumbnailS3Bucket sql.NullString
VideoThumbnailS3Key sql.NullString VideoThumbnailS3Key sql.NullString
} }
@ -294,7 +266,6 @@ func (q *Queries) SetVideoThumbnailUploaded(ctx context.Context, arg SetVideoThu
arg.VideoThumbnailWidth, arg.VideoThumbnailWidth,
arg.VideoThumbnailHeight, arg.VideoThumbnailHeight,
arg.VideoThumbnailMimeType, arg.VideoThumbnailMimeType,
arg.VideoThumbnailS3Bucket,
arg.VideoThumbnailS3Key, arg.VideoThumbnailS3Key,
) )
var i MediaSet var i MediaSet
@ -306,17 +277,14 @@ func (q *Queries) SetVideoThumbnailUploaded(ctx context.Context, arg SetVideoThu
&i.AudioFramesApprox, &i.AudioFramesApprox,
&i.AudioFrames, &i.AudioFrames,
&i.AudioSampleRate, &i.AudioSampleRate,
&i.AudioRawS3Bucket,
&i.AudioRawS3Key, &i.AudioRawS3Key,
&i.AudioRawS3UploadedAt, &i.AudioRawS3UploadedAt,
&i.AudioEncodedMimeType, &i.AudioEncodedMimeType,
&i.VideoYoutubeItag, &i.VideoYoutubeItag,
&i.VideoS3Bucket,
&i.VideoS3Key, &i.VideoS3Key,
&i.VideoS3UploadedAt, &i.VideoS3UploadedAt,
&i.VideoMimeType, &i.VideoMimeType,
&i.VideoDurationNanos, &i.VideoDurationNanos,
&i.VideoThumbnailS3Bucket,
&i.VideoThumbnailS3Key, &i.VideoThumbnailS3Key,
&i.VideoThumbnailS3UploadedAt, &i.VideoThumbnailS3UploadedAt,
&i.VideoThumbnailMimeType, &i.VideoThumbnailMimeType,
@ -326,7 +294,6 @@ func (q *Queries) SetVideoThumbnailUploaded(ctx context.Context, arg SetVideoThu
&i.UpdatedAt, &i.UpdatedAt,
&i.AudioContentLength, &i.AudioContentLength,
&i.VideoContentLength, &i.VideoContentLength,
&i.AudioEncodedS3Bucket,
&i.AudioEncodedS3Key, &i.AudioEncodedS3Key,
&i.AudioEncodedS3UploadedAt, &i.AudioEncodedS3UploadedAt,
) )
@ -335,19 +302,18 @@ func (q *Queries) SetVideoThumbnailUploaded(ctx context.Context, arg SetVideoThu
const setVideoUploaded = `-- name: SetVideoUploaded :one const setVideoUploaded = `-- name: SetVideoUploaded :one
UPDATE media_sets UPDATE media_sets
SET video_s3_bucket = $2, video_s3_key = $3, video_s3_uploaded_at = NOW(), updated_at = NOW() SET video_s3_key = $2, video_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1 WHERE id = $1
RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_bucket, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_bucket, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_bucket, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_bucket, audio_encoded_s3_key, audio_encoded_s3_uploaded_at RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at
` `
type SetVideoUploadedParams struct { type SetVideoUploadedParams struct {
ID uuid.UUID ID uuid.UUID
VideoS3Bucket sql.NullString
VideoS3Key sql.NullString VideoS3Key sql.NullString
} }
func (q *Queries) SetVideoUploaded(ctx context.Context, arg SetVideoUploadedParams) (MediaSet, error) { func (q *Queries) SetVideoUploaded(ctx context.Context, arg SetVideoUploadedParams) (MediaSet, error) {
row := q.db.QueryRow(ctx, setVideoUploaded, arg.ID, arg.VideoS3Bucket, arg.VideoS3Key) row := q.db.QueryRow(ctx, setVideoUploaded, arg.ID, arg.VideoS3Key)
var i MediaSet var i MediaSet
err := row.Scan( err := row.Scan(
&i.ID, &i.ID,
@ -357,17 +323,14 @@ func (q *Queries) SetVideoUploaded(ctx context.Context, arg SetVideoUploadedPara
&i.AudioFramesApprox, &i.AudioFramesApprox,
&i.AudioFrames, &i.AudioFrames,
&i.AudioSampleRate, &i.AudioSampleRate,
&i.AudioRawS3Bucket,
&i.AudioRawS3Key, &i.AudioRawS3Key,
&i.AudioRawS3UploadedAt, &i.AudioRawS3UploadedAt,
&i.AudioEncodedMimeType, &i.AudioEncodedMimeType,
&i.VideoYoutubeItag, &i.VideoYoutubeItag,
&i.VideoS3Bucket,
&i.VideoS3Key, &i.VideoS3Key,
&i.VideoS3UploadedAt, &i.VideoS3UploadedAt,
&i.VideoMimeType, &i.VideoMimeType,
&i.VideoDurationNanos, &i.VideoDurationNanos,
&i.VideoThumbnailS3Bucket,
&i.VideoThumbnailS3Key, &i.VideoThumbnailS3Key,
&i.VideoThumbnailS3UploadedAt, &i.VideoThumbnailS3UploadedAt,
&i.VideoThumbnailMimeType, &i.VideoThumbnailMimeType,
@ -377,7 +340,6 @@ func (q *Queries) SetVideoUploaded(ctx context.Context, arg SetVideoUploadedPara
&i.UpdatedAt, &i.UpdatedAt,
&i.AudioContentLength, &i.AudioContentLength,
&i.VideoContentLength, &i.VideoContentLength,
&i.AudioEncodedS3Bucket,
&i.AudioEncodedS3Key, &i.AudioEncodedS3Key,
&i.AudioEncodedS3UploadedAt, &i.AudioEncodedS3UploadedAt,
) )

View File

@ -132,7 +132,6 @@ func (s *audioGetterState) getAudio(ctx context.Context, r io.ReadCloser, mediaS
if _, err = s.store.SetEncodedAudioUploaded(ctx, store.SetEncodedAudioUploadedParams{ if _, err = s.store.SetEncodedAudioUploaded(ctx, store.SetEncodedAudioUploadedParams{
ID: mediaSet.ID, ID: mediaSet.ID,
AudioEncodedS3Bucket: sqlString(s.config.S3Bucket),
AudioEncodedS3Key: sqlString(key), AudioEncodedS3Key: sqlString(key),
}); err != nil { }); err != nil {
s.CloseWithError(fmt.Errorf("error setting encoded audio uploaded: %v", err)) s.CloseWithError(fmt.Errorf("error setting encoded audio uploaded: %v", err))
@ -155,7 +154,6 @@ func (s *audioGetterState) getAudio(ctx context.Context, r io.ReadCloser, mediaS
if _, err = s.store.SetRawAudioUploaded(ctx, store.SetRawAudioUploadedParams{ if _, err = s.store.SetRawAudioUploaded(ctx, store.SetRawAudioUploadedParams{
ID: mediaSet.ID, ID: mediaSet.ID,
AudioRawS3Bucket: sqlString(s.config.S3Bucket),
AudioRawS3Key: sqlString(key), AudioRawS3Key: sqlString(key),
AudioFrames: sqlInt64(bytesUploaded / SizeOfInt16 / int64(mediaSet.AudioChannels)), AudioFrames: sqlInt64(bytesUploaded / SizeOfInt16 / int64(mediaSet.AudioChannels)),
}); err != nil { }); err != nil {

View File

@ -33,7 +33,7 @@ type videoGetterState struct {
r io.Reader r io.Reader
count, exp int64 count, exp int64
mediaSetID uuid.UUID mediaSetID uuid.UUID
bucket, key, contentType string key, contentType string
url string url string
progressChan chan GetVideoProgress progressChan chan GetVideoProgress
errorChan chan error errorChan chan error
@ -90,7 +90,6 @@ func (s *videoGetterState) getVideo(ctx context.Context) {
storeParams := store.SetVideoUploadedParams{ storeParams := store.SetVideoUploadedParams{
ID: s.mediaSetID, ID: s.mediaSetID,
VideoS3Bucket: sqlString(s.bucket),
VideoS3Key: sqlString(s.key), VideoS3Key: sqlString(s.key),
} }
_, err = s.store.SetVideoUploaded(ctx, storeParams) _, err = s.store.SetVideoUploaded(ctx, storeParams)

View File

@ -563,7 +563,6 @@ func (s *MediaSetService) getThumbnailFromYoutube(ctx context.Context, mediaSet
storeParams := store.SetVideoThumbnailUploadedParams{ storeParams := store.SetVideoThumbnailUploadedParams{
ID: mediaSet.ID, ID: mediaSet.ID,
VideoThumbnailMimeType: sqlString(mimeType), VideoThumbnailMimeType: sqlString(mimeType),
VideoThumbnailS3Bucket: sqlString(s.config.S3Bucket),
VideoThumbnailS3Key: sqlString(thumbnailKey), VideoThumbnailS3Key: sqlString(thumbnailKey),
VideoThumbnailWidth: sqlInt32(int32(thumbnail.Width)), VideoThumbnailWidth: sqlInt32(int32(thumbnail.Width)),
VideoThumbnailHeight: sqlInt32(int32(thumbnail.Height)), VideoThumbnailHeight: sqlInt32(int32(thumbnail.Height)),

View File

@ -0,0 +1,4 @@
ALTER TABLE media_sets ADD COLUMN video_thumbnail_s3_bucket CHARACTER VARYING(256);
ALTER TABLE media_sets ADD COLUMN video_s3_bucket CHARACTER VARYING(256);
ALTER TABLE media_sets ADD COLUMN audio_encoded_s3_bucket CHARACTER VARYING(256);
ALTER TABLE media_sets ADD COLUMN audio_raw_s3_bucket CHARACTER VARYING(256);

View File

@ -0,0 +1,4 @@
ALTER TABLE media_sets DROP COLUMN audio_raw_s3_bucket;
ALTER TABLE media_sets DROP COLUMN audio_encoded_s3_bucket;
ALTER TABLE media_sets DROP COLUMN video_s3_bucket;
ALTER TABLE media_sets DROP COLUMN video_thumbnail_s3_bucket;

View File

@ -11,24 +11,24 @@ INSERT INTO media_sets (youtube_id, audio_youtube_itag, audio_channels, audio_fr
-- name: SetRawAudioUploaded :one -- name: SetRawAudioUploaded :one
UPDATE media_sets UPDATE media_sets
SET audio_raw_s3_bucket = $2, audio_raw_s3_key = $3, audio_frames = $4, audio_raw_s3_uploaded_at = NOW(), updated_at = NOW() SET audio_raw_s3_key = $2, audio_frames = $3, audio_raw_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1 WHERE id = $1
RETURNING *; RETURNING *;
-- name: SetEncodedAudioUploaded :one -- name: SetEncodedAudioUploaded :one
UPDATE media_sets UPDATE media_sets
SET audio_encoded_s3_bucket = $2, audio_encoded_s3_key = $3, audio_encoded_s3_uploaded_at = NOW(), updated_at = NOW() SET audio_encoded_s3_key = $2, audio_encoded_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1 WHERE id = $1
RETURNING *; RETURNING *;
-- name: SetVideoUploaded :one -- name: SetVideoUploaded :one
UPDATE media_sets UPDATE media_sets
SET video_s3_bucket = $2, video_s3_key = $3, video_s3_uploaded_at = NOW(), updated_at = NOW() SET video_s3_key = $2, video_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1 WHERE id = $1
RETURNING *; RETURNING *;
-- name: SetVideoThumbnailUploaded :one -- name: SetVideoThumbnailUploaded :one
UPDATE media_sets UPDATE media_sets
SET video_thumbnail_width = $2, video_thumbnail_height = $3, video_thumbnail_mime_type = $4, video_thumbnail_s3_bucket = $5, video_thumbnail_s3_key = $6, video_thumbnail_s3_uploaded_at = NOW(), updated_at = NOW() SET video_thumbnail_width = $2, video_thumbnail_height = $3, video_thumbnail_mime_type = $4, video_thumbnail_s3_key = $5, video_thumbnail_s3_uploaded_at = NOW(), updated_at = NOW()
WHERE id = $1 WHERE id = $1
RETURNING *; RETURNING *;