You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.5 KiB

  1. CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
  2. CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
  3. CREATE TABLE addresses (
  4. "id" bigserial PRIMARY KEY NOT NULL,
  5. "address_line_1" character varying(255) NOT NULL,
  6. "address_line_2" character varying(255),
  7. "city" character varying(255) NOT NULL,
  8. "region" character varying(255) NOT NULL,
  9. "country" character varying(255) NOT NULL,
  10. "zip_code" character varying(255) NOT NULL,
  11. "phone" character varying(255) NOT NULL,
  12. "uuid" UUID UNIQUE NOT NULL DEFAULT uuid_generate_v4()
  13. );
  14. CREATE TYPE organization_type AS ENUM ('CUSTOMER', 'ENTERPRISE', 'ENTERPRISE_CUSTOMER');
  15. CREATE TABLE organizations (
  16. "id" bigserial PRIMARY KEY NOT NULL,
  17. "name" character varying(100) NOT NULL,
  18. "address_id" integer UNIQUE NOT NULL REFERENCES addresses("id"),
  19. "type" organization_type NOT NULL,
  20. "created_at" timestamp with time zone NOT NULL DEFAULT NOW(),
  21. "uuid" UUID UNIQUE NOT NULL DEFAULT uuid_generate_v4()
  22. );
  23. CREATE TABLE enterprise_sales_enterprise_customers (
  24. "sales_organization_id" bigint NOT NULL REFERENCES organizations("id"),
  25. "customer_organization_id" bigint NOT NULL REFERENCES organizations("id"),
  26. CONSTRAINT sales_organization_customer_organization_key PRIMARY KEY (
  27. sales_organization_id,
  28. customer_organization_id
  29. )
  30. );
  31. CREATE TABLE japan_segments (
  32. "id" character varying(24) PRIMARY KEY NOT NULL,
  33. "bounds" geometry(Polygon,4326) NOT NULL
  34. );