~mna/hockeysim

ref: 9152d214d2eb86b42b88f1631c929f92e9f2434d hockeysim/db/migrations/011_seasons.sql -rw-r--r-- 534 bytes View raw
9152d214Martin Angers implement league archive command 1 year, 20 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
CREATE TABLE seasons (
  id        INT UNSIGNED NOT NULL AUTO_INCREMENT,
  league_id INT UNSIGNED NOT NULL,
  year      TINYINT UNSIGNED NOT NULL,
  state     TINYINT UNSIGNED NOT NULL DEFAULT 0, -- 0: unstarted, 1: started, 2: completed
  created   TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated   TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

  PRIMARY KEY (id),
  UNIQUE INDEX ix_seasons_league_id_year (league_id, year),
  FOREIGN KEY (league_id) REFERENCES leagues (id) ON DELETE CASCADE
);