-- Add migration script here
CREATE TABLE users (
  'id' INTEGER PRIMARY KEY NOT NULL ,
  'uuid' TEXT UNIQUE NOT NULL,
  'username' TEXT NOT NULL,
  'hash' TEXT NOT NULL,
  'email' TEXT NOT NULL
);

CREATE TABLE inventories (
  'id' INTEGER PRIMARY KEY NOT NULL ,
  'uuid' TEXT UNIQUE NOT NULL,
  'user' INTEGER NOT NULL,
  FOREIGN KEY ('user') REFERENCES users ('id')
);

CREATE TABLE user_items (
  'id' INTEGER PRIMARY KEY NOT NULL ,
  'uuid' TEXT UNIQUE NOT NULL,
  'inventory' INTEGER NOT NULL,
  'item' INTEGER NOT NULL,
  FOREIGN KEY ('inventory') REFERENCES inventories ('id'),
  FOREIGN KEY ('item') REFERENCES items ('id')
);

CREATE TABLE items (
  'id' INTEGER PRIMARY KEY NOT NULL ,
  'uuid' TEXT UNIQUE NOT NULL,
  'name' TEXT NOT NULL,
  'rarity' INTEGER NOT NULL,
  'image' TEXT NOT NULL,
  'case' INTEGER NOT NULL,
  FOREIGN KEY ('case') REFERENCES cases ('id')
);

CREATE TABLE cases (
  'id' INTEGER PRIMARY KEY NOT NULL ,
  'uuid' TEXT UNIQUE NOT NULL,
  'name' TEXT NOT NULL,
  'image' TEXT NOT NULL
);