Skip to content

Instantly share code, notes, and snippets.

@cristianc-ty
Last active February 8, 2018 13:06
Show Gist options
  • Save cristianc-ty/72bde80cb2c01b09edcda2915ff4cd4f to your computer and use it in GitHub Desktop.
Save cristianc-ty/72bde80cb2c01b09edcda2915ff4cd4f to your computer and use it in GitHub Desktop.
db_schema.sql
create extension if not exists "uuid-ossp";
create table business (
id uuid default uuid_generate_v4() primary key,
name character varying not null
);
create table customer (
id uuid default uuid_generate_v4() primary key,
business_id uuid references business(id),
name character varying not null,
profile_data jsonb default '{}'::jsonb not null,
created_at timestamp without time zone not null,
updated_at timestamp without time zone not null,
deleted_at timestamp without time zone
);
create table email (
id uuid default uuid_generate_v4() primary key,
customer_id uuid references customer(id),
email_address character varying not null,
created_at timestamp without time zone not null,
updated_at timestamp without time zone not null,
deleted_at timestamp without time zone
);
create index idx_deleted_at_on_email on email using btree (deleted_at);
create index idx_customer_id_on_email on email using btree (customer_id);
create table phone (
id uuid default uuid_generate_v4() primary key,
customer_id uuid references customer(id),
phone_number character varying not null,
national_format character varying not null,
created_at timestamp without time zone not null,
updated_at timestamp without time zone not null,
deleted_at timestamp without time zone
);
create index idx_deleted_at_on_phone on phone using btree (deleted_at);
create index idx_customer_id_on_phone on phone using btree (customer_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment