bazzar/migrations/20230603073520_identity.sql
2023-06-19 17:09:53 +02:00

77 lines
2.5 KiB
SQL

CREATE TABLE customers
(
id uuid NOT NULL,
email character varying NOT NULL,
first_name character varying,
last_name character varying,
billing_address_id uuid,
password_hash character varying,
phone character varying,
has_account boolean DEFAULT false NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
deleted_at timestamp with time zone,
metadata jsonb
);
CREATE TABLE customer_groups
(
id uuid NOT NULL,
name character varying NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
deleted_at timestamp with time zone,
metadata jsonb
);
CREATE TABLE customer_group_customers
(
customer_group_id uuid NOT NULL,
customer_id uuid NOT NULL
);
------------------------------------------
------------------------------------------
------------------------------------------
CREATE TYPE user_roles AS ENUM (
'admin',
'member',
'developer'
);
CREATE TABLE users
(
id uuid NOT NULL,
email character varying NOT NULL,
first_name character varying,
last_name character varying,
password_hash character varying,
api_token character varying,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
deleted_at timestamp with time zone,
metadata jsonb,
role user_roles DEFAULT 'member'::user_roles
);
CREATE TABLE addresses
(
id uuid NOT NULL,
customer_id uuid,
company character varying,
first_name character varying,
last_name character varying,
address_1 character varying,
address_2 character varying,
city character varying,
country_code character varying,
province character varying,
postal_code character varying,
phone character varying,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
deleted_at timestamp with time zone,
metadata jsonb
);