mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-16 08:25:14 +02:00
Initial open-source release
This commit is contained in:
commit
1a42152e6f
1199 changed files with 257054 additions and 0 deletions
51
examples/postgres-historic/init/001-schema.sql
Normal file
51
examples/postgres-historic/init/001-schema.sql
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
|
||||
|
||||
CREATE ROLE app_user LOGIN PASSWORD 'app_pass';
|
||||
CREATE ROLE etl_user LOGIN PASSWORD 'etl_pass';
|
||||
CREATE ROLE klo_reader LOGIN PASSWORD 'klo_reader';
|
||||
|
||||
GRANT pg_read_all_stats TO klo_reader;
|
||||
|
||||
CREATE TABLE customers (
|
||||
id integer PRIMARY KEY,
|
||||
region text NOT NULL,
|
||||
plan text NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE orders (
|
||||
id integer PRIMARY KEY,
|
||||
customer_id integer NOT NULL REFERENCES customers(id),
|
||||
status text NOT NULL,
|
||||
total numeric(12, 2) NOT NULL,
|
||||
created_at timestamptz NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE events (
|
||||
id integer PRIMARY KEY,
|
||||
customer_id integer NOT NULL REFERENCES customers(id),
|
||||
event_name text NOT NULL,
|
||||
occurred_at timestamptz NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO customers (id, region, plan) VALUES
|
||||
(1, 'na', 'enterprise'),
|
||||
(2, 'na', 'team'),
|
||||
(3, 'eu', 'enterprise'),
|
||||
(4, 'apac', 'team');
|
||||
|
||||
INSERT INTO orders (id, customer_id, status, total, created_at) VALUES
|
||||
(1, 1, 'paid', 125.50, now() - interval '9 days'),
|
||||
(2, 1, 'paid', 89.00, now() - interval '4 days'),
|
||||
(3, 2, 'pending', 42.00, now() - interval '2 days'),
|
||||
(4, 3, 'paid', 301.25, now() - interval '1 day'),
|
||||
(5, 4, 'refunded', 77.70, now() - interval '3 hours');
|
||||
|
||||
INSERT INTO events (id, customer_id, event_name, occurred_at) VALUES
|
||||
(1, 1, 'dashboard_viewed', now() - interval '1 day'),
|
||||
(2, 1, 'export_started', now() - interval '8 hours'),
|
||||
(3, 2, 'dashboard_viewed', now() - interval '7 hours'),
|
||||
(4, 3, 'sync_completed', now() - interval '6 hours'),
|
||||
(5, 4, 'dashboard_viewed', now() - interval '5 hours');
|
||||
|
||||
GRANT USAGE ON SCHEMA public TO app_user, etl_user, klo_reader;
|
||||
GRANT SELECT ON ALL TABLES IN SCHEMA public TO app_user, etl_user, klo_reader;
|
||||
Loading…
Add table
Add a link
Reference in a new issue