@@ -50,31 +50,33 @@ PGPASSWORD="$POSTGRES_PASSWORD" psql -v ON_ERROR_STOP=1 -h "$POSTGRES_HOST" -p "
5050
5151CREATE SCHEMA IF NOT EXISTS analytics;
5252
53- CREATE OR REPLACE VIEW analytics.locations
54- WITH (security_barrier)
55- AS
56- SELECT * FROM app.locations;
53+ CREATE TABLE IF NOT EXISTS analytics.locations (
54+ id TEXT PRIMARY KEY,
55+ name text NOT NULL,
56+ parent_id TEXT REFERENCES analytics.locations(id),
57+ location_type TEXT NOT NULL
58+ );
5759
5860CREATE TABLE IF NOT EXISTS analytics.event_actions (
5961 event_type text NOT NULL,
60- action_type app.action_type NOT NULL,
62+ action_type TEXT NOT NULL,
6163 annotation jsonb,
6264 assigned_to text,
6365 created_at timestamp with time zone NOT NULL DEFAULT now(),
64- created_at_location uuid REFERENCES app.locations(id) ,
66+ created_at_location TEXT ,
6567 created_by text NOT NULL,
6668 created_by_role text NOT NULL,
6769 created_by_signature text,
68- created_by_user_type app.user_type NOT NULL,
70+ created_by_user_type TEXT NOT NULL,
6971 declared_at timestamp with time zone,
7072 registered_at timestamp with time zone,
7173 declaration jsonb NOT NULL DEFAULT '{}'::jsonb,
72- event_id uuid NOT NULL REFERENCES app.events(id) ,
74+ event_id uuid NOT NULL,
7375 id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
74- original_action_id uuid REFERENCES app.event_actions(id) ,
76+ original_action_id uuid,
7577 registration_number text UNIQUE,
7678 request_id text,
77- status app.action_status NOT NULL,
79+ status TEXT NOT NULL,
7880 transaction_id text NOT NULL,
7981 content jsonb,
8082 UNIQUE (id, event_id)
0 commit comments