feat: add the calendar feed model and migration

This commit is contained in:
Jakub Zych
2026-10-02 17:38:48 +02:00
parent 28f68d002f
commit bccb747171
3 changed files with 106 additions and 0 deletions

View 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
},
}
}