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.
36 lines
1.2 KiB
Go
36 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"
|
|
)
|
|
|
|
// CreateMaterials returns the 20261002120209_create_jz_bm_materials gormigrate entry:
|
|
// the study materials; a NULL published_at is a draft. Deleting a course keeps its materials, unlinked.
|
|
func CreateMaterials() *gormigrate.Migration {
|
|
return &gormigrate.Migration{
|
|
ID: "20261002120209_create_jz_bm_materials",
|
|
Migrate: func(tx *gorm.DB) error {
|
|
return execAll(tx, `CREATE TABLE jz_bm_materials (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
course_id BIGINT NULL REFERENCES jz_bm_courses (id) ON DELETE SET NULL,
|
|
title VARCHAR(255) NOT NULL,
|
|
type VARCHAR(20) NOT NULL CHECK (type IN ('pdf', 'notatka', 'link', 'inne')),
|
|
body TEXT NULL,
|
|
source VARCHAR(500) NULL,
|
|
url VARCHAR(2048) NULL,
|
|
published_at TIMESTAMPTZ NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
CREATE INDEX jz_bm_materials_published_at_index ON jz_bm_materials (published_at);
|
|
CREATE INDEX jz_bm_materials_course_id_index ON jz_bm_materials (course_id)`)
|
|
},
|
|
Rollback: func(tx *gorm.DB) error {
|
|
return tx.Exec("DROP TABLE IF EXISTS jz_bm_materials").Error
|
|
},
|
|
}
|
|
}
|