zrok/controller/store/sql/000_base.sql

49 lines
1.9 KiB
MySQL
Raw Normal View History

-- +migrate Up
--
2022-07-25 22:03:51 +02:00
-- accounts
--
2022-07-25 22:03:51 +02:00
create table accounts (
2022-08-03 19:43:54 +02:00
id integer primary key,
2022-09-09 16:20:05 +02:00
email string not null unique,
2022-08-03 19:43:54 +02:00
password string not null,
token string not null unique,
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
2022-09-09 16:20:05 +02:00
constraint chk_email check (email <> ''),
constraint chk_password check (password <> ''),
constraint chk_token check(token <> '')
);
2022-07-29 17:10:39 +02:00
2022-07-29 19:33:55 +02:00
--
2022-08-03 19:43:54 +02:00
-- environments
2022-07-29 19:33:55 +02:00
--
2022-08-03 19:43:54 +02:00
create table environments (
id integer primary key,
account_id integer constraint fk_accounts_identities references accounts on delete cascade,
description string,
host string,
address string,
ziti_identity_id string not null unique,
active boolean not null,
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
2022-07-29 19:33:55 +02:00
2022-08-03 19:43:54 +02:00
constraint chk_ziti_identity_id check (ziti_identity_id <> '')
2022-07-29 19:33:55 +02:00
);
2022-07-29 17:10:39 +02:00
--
-- services
--
create table services (
2022-08-03 19:43:54 +02:00
id integer primary key,
2022-08-03 20:58:11 +02:00
environment_id integer constraint fk_environments_services references environments on delete cascade,
2022-08-03 19:43:54 +02:00
ziti_service_id string not null unique,
endpoint string,
active boolean not null,
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
2022-07-29 19:27:00 +02:00
2022-08-03 19:43:54 +02:00
constraint chk_ziti_service_id check (ziti_service_id <> '')
2022-07-29 17:10:39 +02:00
);