-- mysql -u shmyga -pxkbp8jh9z2 armageddon --protocol TCP
CREATE USER 'shmyga'@'localhost' IDENTIFIED BY 'xkbp8jh9z2';

DROP DATABASE IF EXISTS armageddon;
CREATE DATABASE IF NOT EXISTS armageddon;
GRANT ALL ON armageddon.* TO 'shmyga'@'localhost' IDENTIFIED BY 'xkbp8jh9z2';


DROP TABLE IF EXISTS armageddon.account;
CREATE TABLE IF NOT EXISTS armageddon.account (
  id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
  login VARCHAR(255) UNIQUE,
  password VARCHAR(32)
);

DROP TABLE IF EXISTS armageddon.person;
CREATE TABLE IF NOT EXISTS armageddon.person (
  id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
  account_id INT UNSIGNED NOT NULL,
  name VARCHAR(255),

  CONSTRAINT person_2_account FOREIGN KEY (account_id) REFERENCES armageddon.account(id)
    MATCH SIMPLE ON DELETE CASCADE ON UPDATE NO ACTION
);

INSERT INTO armageddon.account (id,login,password) VALUES(1,'shmyga', 'd48cc4eb42c058869ae90daef9606e43');
INSERT INTO armageddon.person (id,account_id,name) VALUES(1,1,'-=Shmyga=-');

INSERT INTO armageddon.account (id,login,password) VALUES(2,'a', md5('a'));
INSERT INTO armageddon.person (id,account_id,name) VALUES(2,2,'a');

