x3dh25519.sql 1.11 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;

DROP DATABASE IF EXISTS `x3dh25519`;
CREATE DATABASE `x3dh25519` CHARACTER SET utf8 COLLATE utf8_bin;
USE `x3dh25519`;

START TRANSACTION;

DROP TABLE IF EXISTS `Users`;
CREATE TABLE `Users` (
	`Uid` INTEGER NOT NULL AUTO_INCREMENT,
	`UserId` TEXT COLLATE utf8_bin NOT NULL,
	`Ik` BLOB NOT NULL,
	`SPk` BLOB DEFAULT NULL,
	`SPk_sig` BLOB DEFAULT NULL,
	`SPk_id` INTEGER UNSIGNED DEFAULT NULL,
	PRIMARY KEY(`Uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

DROP TABLE IF EXISTS `OPk`;
CREATE TABLE `OPk` (
	`id` INTEGER NOT NULL AUTO_INCREMENT,
	`Uid` INTEGER NOT NULL,
	`OPk` BLOB NOT NULL,
	`OPk_id` INTEGER UNSIGNED NOT NULL,
	PRIMARY KEY(`id`),
	FOREIGN KEY(`Uid`) REFERENCES Users(`Uid`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

DROP TABLE IF EXISTS `Config`;
CREATE TABLE `Config` (
	`Name` VARCHAR(20) COLLATE utf8_bin DEFAULT NULL,
	`Value` INTEGER NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

INSERT INTO `Config` (`Name`, `Value`) VALUES
('version', 1),
('curveId', 25519);

COMMIT;