-- +goose Up
CREATE TABLE IF NOT EXISTS duls (
  id BINARY(16) NOT NULL,
  no BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  name VARCHAR(128) NOT NULL,
  date DATE NOT NULL,
  info TEXT NULL,
  base_id BINARY(16) NOT NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  created_by BINARY(16) NULL,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  updated_by BINARY(16) NULL,
  deleted_at DATETIME NULL,
  deleted_by BINARY(16) NULL,
  PRIMARY KEY (id),
  UNIQUE KEY uq_duls_no (no),
  KEY idx_duls_base_id (base_id),
  CONSTRAINT fk_duls_base FOREIGN KEY (base_id) REFERENCES bases(id) ON UPDATE CASCADE ON DELETE RESTRICT
);

-- +goose Down
DROP TABLE IF EXISTS duls;
