diff options
| author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-08-17 18:29:33 -0400 |
|---|---|---|
| committer | simponic <simponic@hatecomputers.club> | 2024-08-17 18:29:33 -0400 |
| commit | b1775c4408bb00803eba321aa66ab92d6ba45580 (patch) | |
| tree | 90179edff8951b06abb91495ce21c8b1841d2d82 /database/migrate.go | |
| parent | 0b8883c236a06a14e5e6958ed47f89729b0e41aa (diff) | |
| download | hatecomputers.club-b1775c4408bb00803eba321aa66ab92d6ba45580.tar.gz hatecomputers.club-b1775c4408bb00803eba321aa66ab92d6ba45580.zip | |
kennel (#13)
Reviewed-on: https://git.hatecomputers.club/hatecomputers/hatecomputers.club/pulls/13
Co-authored-by: Elizabeth Hunt <elizabeth@simponic.xyz>
Co-committed-by: Elizabeth Hunt <elizabeth@simponic.xyz>
Diffstat (limited to 'database/migrate.go')
| -rw-r--r-- | database/migrate.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/database/migrate.go b/database/migrate.go index e9e21b7..0c8318c 100644 --- a/database/migrate.go +++ b/database/migrate.go @@ -162,6 +162,26 @@ func MigrateProfiles(dbConn *sql.DB) (*sql.DB, error) { return dbConn, nil } +func MigrateKennel(dbConn *sql.DB) (*sql.DB, error) { + log.Println("migrating kennel tables") + + _, err := dbConn.Exec(`CREATE TABLE IF NOT EXISTS kennel_cat ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL, + user_id INTEGER NOT NULL, + link TEXT NOT NULL, + description TEXT NOT NULL, + spritesheet TEXT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE + );`) + if err != nil { + return dbConn, err + } + + return dbConn, nil +} + func Migrate(dbConn *sql.DB) (*sql.DB, error) { log.Println("migrating database") @@ -173,6 +193,7 @@ func Migrate(dbConn *sql.DB) (*sql.DB, error) { MigrateDNSRecords, MigrateGuestBook, MigrateProfiles, + MigrateKennel, } for _, migration := range migrations { |
