mentorenwahl/docker/backend/db/migrations/20220120165453_create_votes.sql

27 lines
635 B
MySQL
Raw Normal View History

-- +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;