quintodrome/db/migrations/20230119152657_recreate_share_table.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
946 B
Go
Raw Normal View History

2023-01-19 18:52:55 -09:00
package migrations
import (
2023-11-27 10:46:44 -09:00
"context"
2023-01-19 18:52:55 -09:00
"database/sql"
2023-04-04 05:57:00 -08:00
"github.com/pressly/goose/v3"
2023-01-19 18:52:55 -09:00
)
func init() {
2023-11-27 10:46:44 -09:00
goose.AddMigrationContext(upAddMissingShareInfo, downAddMissingShareInfo)
2023-01-19 18:52:55 -09:00
}
2023-11-27 10:46:44 -09:00
func upAddMissingShareInfo(_ context.Context, tx *sql.Tx) error {
2023-01-19 18:52:55 -09:00
_, err := tx.Exec(`
drop table if exists share;
create table share
(
id varchar(255) not null
primary key,
description varchar(255),
expires_at datetime,
last_visited_at datetime,
resource_ids varchar not null,
resource_type varchar(255) not null,
contents varchar,
format varchar,
max_bit_rate integer,
visit_count integer default 0,
created_at datetime,
updated_at datetime,
user_id varchar(255) not null
constraint share_user_id_fk
references user
);
`)
return err
}
2023-11-27 10:46:44 -09:00
func downAddMissingShareInfo(_ context.Context, tx *sql.Tx) error {
2023-01-19 18:52:55 -09:00
return nil
}