SQL

CREATE TABLE `standings`  (
  `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
  `competition_id` integer NOT NULL,
  `manager_id` integer NOT NULL,
  `total_points` real DEFAULT 0 NOT NULL,
  `matchdays_played` integer DEFAULT 0 NOT NULL,
  `rank` integer,
  `updated_at` text DEFAULT (datetime('now')),
  FOREIGN KEY (`competition_id`) REFERENCES `competitions`(`id`) ON UPDATE no action ON DELETE no action,
  FOREIGN KEY (`manager_id`) REFERENCES `managers`(`id`) ON UPDATE no action ON DELETE no action
)

+ Add column

Columns

Column Data type Allow null Primary key Actions
id INTEGER Rename | Drop
competition_id INTEGER Rename | Drop
manager_id INTEGER Rename | Drop
total_points REAL Rename | Drop
matchdays_played INTEGER Rename | Drop
rank INTEGER Rename | Drop
updated_at TEXT Rename | Drop

Foreign Keys

Column Destination
manager_id managers.id
competition_id competitions.id

+ Add index

Indexes

Name Columns Unique SQL Drop?
uq_standings
  • competition_id
  • manager_id
SQL
CREATE UNIQUE INDEX `uq_standings`
ON `standings` (`competition_id`,`manager_id`)
Drop