| 9 | ) |
| 10 | |
| 11 | func init() { |
| 12 | // The version of this migration |
| 13 | const migrationVersion = 2 |
| 14 | |
| 15 | Register( |
| 16 | migrationVersion, |
| 17 | func(ctx context.Context, tx pgx.Tx) error { |
| 18 | // The Up action of this migration |
| 19 | // Delete all cached entries |
| 20 | _, err := tx.Exec(ctx, `TRUNCATE cache;`) |
| 21 | if err != nil { |
| 22 | return err |
| 23 | } |
| 24 | |
| 25 | _, err = tx.Exec(ctx, ` |
| 26 | ALTER TABLE cache |
| 27 | ADD http_status_code SMALLINT NOT NULL, |
| 28 | ADD http_content_type TEXT NOT NULL |
| 29 | ;`) |
| 30 | |
| 31 | return err |
| 32 | }, |
| 33 | func(ctx context.Context, tx pgx.Tx) error { |
| 34 | // The Down action of this migration |
| 35 | _, err := tx.Exec(ctx, ` |
| 36 | ALTER TABLE cache |
| 37 | DROP http_status_code, |
| 38 | DROP http_content_type |
| 39 | ;`) |
| 40 | |
| 41 | return err |
| 42 | }, |
| 43 | ) |
| 44 | } |