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.
39 lines
1.4 KiB
Go
39 lines
1.4 KiB
Go
// Code generated by summer make. DO NOT EDIT.
|
|
|
|
package updates
|
|
|
|
import (
|
|
"github.com/go-gormigrate/gormigrate/v2"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// CreateClassSessions returns the 20261002120204_create_jz_bm_class_sessions gormigrate entry:
|
|
// the zajęcia. Deleting a course deletes its sessions; deleting a meeting keeps them.
|
|
func CreateClassSessions() *gormigrate.Migration {
|
|
return &gormigrate.Migration{
|
|
ID: "20261002120204_create_jz_bm_class_sessions",
|
|
Migrate: func(tx *gorm.DB) error {
|
|
return execAll(tx, `CREATE TABLE jz_bm_class_sessions (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
course_id BIGINT NOT NULL REFERENCES jz_bm_courses (id) ON DELETE CASCADE,
|
|
meeting_id BIGINT NULL REFERENCES jz_bm_meetings (id) ON DELETE SET NULL,
|
|
starts_at TIMESTAMPTZ NOT NULL,
|
|
ends_at TIMESTAMPTZ NOT NULL,
|
|
room VARCHAR(100) NULL,
|
|
kind VARCHAR(100) NULL,
|
|
notes TEXT NULL,
|
|
is_online BOOLEAN NOT NULL DEFAULT FALSE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
CHECK (ends_at > starts_at),
|
|
UNIQUE (course_id, starts_at)
|
|
);
|
|
CREATE INDEX jz_bm_class_sessions_starts_at_index ON jz_bm_class_sessions (starts_at);
|
|
CREATE INDEX jz_bm_class_sessions_meeting_id_index ON jz_bm_class_sessions (meeting_id)`)
|
|
},
|
|
Rollback: func(tx *gorm.DB) error {
|
|
return tx.Exec("DROP TABLE IF EXISTS jz_bm_class_sessions").Error
|
|
},
|
|
}
|
|
}
|