feat: add the calendar feed model and migration
This commit is contained in:
32
updates/20261002153237_create_jz_bm_calendar_feeds.go
Normal file
32
updates/20261002153237_create_jz_bm_calendar_feeds.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by summer make. DO NOT EDIT.
|
||||
|
||||
package updates
|
||||
|
||||
import (
|
||||
"github.com/go-gormigrate/gormigrate/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// CreateCalendarFeeds returns the 20261002153237_create_jz_bm_calendar_feeds gormigrate entry:
|
||||
// one subscribable ICS feed per golem15.user user, addressed by a secret token.
|
||||
func CreateCalendarFeeds() *gormigrate.Migration {
|
||||
return &gormigrate.Migration{
|
||||
ID: "20261002153237_create_jz_bm_calendar_feeds",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
return execAll(tx, `CREATE TABLE jz_bm_calendar_feeds (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
user_id INTEGER NOT NULL UNIQUE REFERENCES users (id) ON DELETE CASCADE,
|
||||
token VARCHAR(64) NOT NULL UNIQUE,
|
||||
excluded_course_ids JSONB NOT NULL DEFAULT '[]'::jsonb CHECK (jsonb_typeof(excluded_course_ids) = 'array'),
|
||||
include_meetings BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
include_deadlines BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
last_fetched_at TIMESTAMPTZ NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
)`)
|
||||
},
|
||||
Rollback: func(tx *gorm.DB) error {
|
||||
return tx.Exec("DROP TABLE IF EXISTS jz_bm_calendar_feeds").Error
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user