27 lines
635 B
MySQL
27 lines
635 B
MySQL
|
-- +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;
|