Files
sm-bm-plugin/updates/20261002120205_create_jz_bm_deadlines.go
Jakub Zych 1046237771 feat: add the study data models and schema migrations
Courses, meetings, class sessions, deadlines, readings with per-user
progress, materials with tags and file attachments. Timestamps are
stored in UTC and held as Europe/Warsaw text so the admin text inputs
can write them.
2026-10-02 14:26:08 +02:00

34 lines
1.2 KiB
Go

// Code generated by summer make. DO NOT EDIT.
package updates
import (
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)
// CreateDeadlines returns the 20261002120205_create_jz_bm_deadlines gormigrate entry:
// the terminarz. Deleting a course keeps its deadlines, unlinked.
func CreateDeadlines() *gormigrate.Migration {
return &gormigrate.Migration{
ID: "20261002120205_create_jz_bm_deadlines",
Migrate: func(tx *gorm.DB) error {
return execAll(tx, `CREATE TABLE jz_bm_deadlines (
id BIGSERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
due_at TIMESTAMPTZ NOT NULL,
course_id BIGINT NULL REFERENCES jz_bm_courses (id) ON DELETE SET NULL,
kind VARCHAR(20) NOT NULL CHECK (kind IN ('zaliczenie', 'egzamin', 'praca', 'organizacyjne', 'inne')),
description TEXT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX jz_bm_deadlines_due_at_index ON jz_bm_deadlines (due_at);
CREATE INDEX jz_bm_deadlines_course_id_index ON jz_bm_deadlines (course_id)`)
},
Rollback: func(tx *gorm.DB) error {
return tx.Exec("DROP TABLE IF EXISTS jz_bm_deadlines").Error
},
}
}