-- +micrate Up
-- SQL in section 'Up' is executed when this migration is applied
CREATE TABLE admins(
  id BIGSERIAL PRIMARY KEY,
  user_id BIGINT NOT NULL UNIQUE REFERENCES users(id)
);

CREATE TABLE teachers(
  id BIGSERIAL PRIMARY KEY,
  user_id BIGINT NOT NULL UNIQUE REFERENCES users(id),
  max_students INT NOT NULL,
  skif BOOLEAN NOT NULL
);

CREATE TABLE students(
  id BIGSERIAL PRIMARY KEY,
  user_id BIGINT NOT NULL UNIQUE REFERENCES users(id),
  skif BOOLEAN NOT NULL
);

ALTER TABLE
  users
ADD
  COLUMN admin_id BIGINT UNIQUE REFERENCES admins(id);

ALTER TABLE
  users
ADD
  COLUMN teacher_id BIGINT UNIQUE REFERENCES teachers(id);

ALTER TABLE
  users
ADD
  COLUMN student_id BIGINT UNIQUE REFERENCES students(id);

-- +micrate Down
-- SQL section 'Down' is executed when this migration is rolled back
ALTER TABLE
  users DROP COLUMN admin_id;

ALTER TABLE
  users DROP COLUMN teacher_id;

ALTER TABLE
  users DROP COLUMN student_id;

DROP TABLE admins;

DROP TABLE teachers;

DROP TABLE students;