mentorenwahl/docker/backend/db/migrations/20220120165453_create_votes.sql
Dominic Grimm 5bc10f8aaf
Some checks failed
continuous-integration/drone/push Build is failing
Added worker
2022-01-23 09:12:57 +01:00

27 lines
635 B
SQL

-- +micrate Up
-- SQL in section 'Up' is executed when this migration is applied
CREATE TABLE votes(
id BIGSERIAL PRIMARY KEY,
student_id BIGINT NOT NULL UNIQUE REFERENCES students(id)
);
ALTER TABLE
students
ADD
COLUMN vote_id BIGINT UNIQUE REFERENCES votes(id);
CREATE TABLE teacher_votes(
id BIGSERIAL PRIMARY KEY,
vote_id BIGINT NOT NULL REFERENCES votes(id),
teacher_id BIGINT NOT NULL REFERENCES teachers(id),
priority INT NOT NULL
);
-- +micrate Down
-- SQL section 'Down' is executed when this migration is rolled back
ALTER TABLE
students DROP COLUMN vote_id;
DROP TABLE teacher_votes;
DROP TABLE votes;