-- migrate:up -- Each person has their own courses, associations and calendars: they are owned by the -- login given by Authelia (`Remote-User`). Everything else (slots, grades, tasks, -- files, events) belongs to the owner of its course or calendar. The tags stay shared. -- What existed before is given to the first user of the app. ALTER TABLE courses ADD COLUMN "owner" TEXT; UPDATE courses SET "owner" = 'appellet'; ALTER TABLE courses ALTER COLUMN "owner" SET NOT NULL; -- The folders are in the folder of their owner in the storage: two people may have the -- same course ALTER TABLE courses DROP CONSTRAINT courses_folder_key; ALTER TABLE courses ADD CONSTRAINT courses_owner_folder_key UNIQUE ("owner", folder); ALTER TABLE calendars ADD COLUMN "owner" TEXT; UPDATE calendars SET "owner" = 'appellet'; ALTER TABLE calendars ALTER COLUMN "owner" SET NOT NULL; CREATE INDEX calendars_owner_idx ON calendars ("owner"); -- migrate:down DROP INDEX IF EXISTS calendars_owner_idx; ALTER TABLE calendars DROP COLUMN "owner"; ALTER TABLE courses DROP CONSTRAINT courses_owner_folder_key; ALTER TABLE courses ADD CONSTRAINT courses_folder_key UNIQUE (folder); ALTER TABLE courses DROP COLUMN "owner";