create database session;
create user 'session-user'@'%' identified by 'session-user';
grant all on session.* to 'session-user'@'%' identified by 'session-user' with grant option;
flush privileges;
use session;


SET FOREIGN_KEY_CHECKS=0;

-- Table structure for table `session`

CREATE TABLE `session` (
 `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 `node` varchar(20) NOT NULL,
 `last_change` TIMESTAMP DEFAULT NOW(),
 `script_running` boolean NOT NULL,
 PRIMARY KEY(`id`)
) ROW_FORMAT=DYNAMIC ENGINE=INNODB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

CREATE TABLE `master` (
 `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 `master` varchar(20) NOT NULL,
 `last_change` int DEFAULT UNIX_TIMESTAMP(),
 PRIMARY KEY(`id`)
) ROW_FORMAT=DYNAMIC ENGINE=INNODB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;



SET FOREIGN_KEY_CHECKS=1;

INSERT INTO session (
  node,
  script_running)
VALUES (
  'init-system',
  false
);

INSERT INTO master (
  master
)
VALUES (
  'init-system'
);
