blob: 3401739999e5961337265d640cc0dc37258213ef (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package migrations
import (
"context"
"database/sql"
"github.com/pressly/goose/v3"
)
func init() {
goose.AddMigrationContext(upSession, downSession)
}
func upSession(ctx context.Context, tx *sql.Tx) error {
_, err := tx.Exec(`CREATE TABLE IF NOT EXISTS devices (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
token VARCHAR(255) NOT NULL
)`)
if err != nil {
return err
}
return nil
}
func downSession(ctx context.Context, tx *sql.Tx) error {
// This code is executed when the migration is rolled back.
_, err := tx.Exec(`DROP TABLE IF EXISTS sessions`)
if err != nil {
return err
}
return nil
}
|