basic schema conversion for postgres (#46)

This commit is contained in:
Michael Quigley 2022-10-21 08:48:31 -04:00
parent bc75b312bf
commit d479ff8609
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,62 @@
-- +migrate Up
--
-- accounts
--
create table accounts (
id integer primary key,
email varchar(1024) not null unique,
password char(128) not null,
token varchar(32) not null unique,
created_at timestamp not null default(current_timestamp),
updated_at timestamp not null default(current_timestamp),
constraint chk_email check (email <> ''),
constraint chk_password check (password <> ''),
constraint chk_token check(token <> '')
);
--
-- account_requests
--
create table account_requests (
id integer primary key,
token varchar(32) not null unique,
email varchar(1024) not null unique,
source_address varchar(64) not null,
created_at timestamp not null default(current_timestamp),
updated_at timestamp not null default(current_timestamp)
);
--
-- environments
--
create table environments (
id integer primary key,
account_id integer constraint fk_accounts_identities references accounts on delete cascade,
description text,
host varchar(256),
address varchar(64),
z_id varchar(32) not null unique,
created_at timestamp not null default(current_timestamp),
updated_at timestamp not null default(current_timestamp),
constraint chk_z_id check (z_id <> '')
);
--
-- services
--
create table services (
id integer primary key,
environment_id integer constraint fk_environments_services references environments on delete cascade,
z_id varchar(32) not null unique,
name varchar(32) not null unique,
frontend varchar(1024),
backend varchar(1024),
created_at timestamp not null default(current_timestamp),
updated_at timestamp not null default(current_timestamp),
constraint chk_z_id check (z_id <> ''),
constraint chk_name check (name <> '')
);

View File

@ -0,0 +1,6 @@
package postgresql_schema
import "embed"
//go:embed *.sql
var FS embed.FS