feat: zjazd (meeting) on readings and materials
The Pulpit hero lists what to read for the current or next zjazd, so readings and materials get a nullable meeting_id (FK to jz_bm_meetings, ON DELETE SET NULL, indexed). The reading admin form gets a "Na zjazd" picker, the student reading JSON carries meeting_id, and the management /readings records filter and validate it.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package updates
|
||||
|
||||
import (
|
||||
"github.com/go-gormigrate/gormigrate/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// AddMeetingToReadingsAndMaterials returns the
|
||||
// 20261027120000_add_meeting_to_readings_and_materials gormigrate entry: a
|
||||
// reading or a material may be assigned to the zjazd (meeting) it should be
|
||||
// read for, so the dashboard can suggest it before that zjazd. Deleting the
|
||||
// meeting keeps the rows and clears the assignment.
|
||||
func AddMeetingToReadingsAndMaterials() *gormigrate.Migration {
|
||||
return &gormigrate.Migration{
|
||||
ID: "20261027120000_add_meeting_to_readings_and_materials",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
return execAll(tx, `
|
||||
ALTER TABLE jz_bm_readings ADD COLUMN meeting_id BIGINT NULL REFERENCES jz_bm_meetings (id) ON DELETE SET NULL;
|
||||
CREATE INDEX jz_bm_readings_meeting_id_index ON jz_bm_readings (meeting_id);
|
||||
ALTER TABLE jz_bm_materials ADD COLUMN meeting_id BIGINT NULL REFERENCES jz_bm_meetings (id) ON DELETE SET NULL;
|
||||
CREATE INDEX jz_bm_materials_meeting_id_index ON jz_bm_materials (meeting_id)`)
|
||||
},
|
||||
Rollback: func(tx *gorm.DB) error {
|
||||
return execAll(tx, `
|
||||
ALTER TABLE jz_bm_readings DROP COLUMN IF EXISTS meeting_id;
|
||||
ALTER TABLE jz_bm_materials DROP COLUMN IF EXISTS meeting_id`)
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user