@@ -50,31 +50,35 @@ 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 uuid PRIMARY KEY,
55+ name text NOT NULL,
56+ parent_id uuid REFERENCES analytics.locations(id),
57+ location_type TEXT NOT NULL
58+ );
59+
60+ CREATE UNIQUE INDEX IF NOT EXISTS analytics_locations_pkey ON analytics.locations(id uuid_ops);
5761
5862CREATE TABLE IF NOT EXISTS analytics.event_actions (
5963 event_type text NOT NULL,
60- action_type app.action_type NOT NULL,
64+ action_type TEXT NOT NULL,
6165 annotation jsonb,
6266 assigned_to text,
6367 created_at timestamp with time zone NOT NULL DEFAULT now(),
64- created_at_location uuid REFERENCES app.locations(id) ,
68+ created_at_location uuid,
6569 created_by text NOT NULL,
6670 created_by_role text NOT NULL,
6771 created_by_signature text,
68- created_by_user_type app.user_type NOT NULL,
72+ created_by_user_type TEXT NOT NULL,
6973 declared_at timestamp with time zone,
7074 registered_at timestamp with time zone,
7175 declaration jsonb NOT NULL DEFAULT '{}'::jsonb,
72- event_id uuid NOT NULL REFERENCES app.events(id) ,
76+ event_id uuid NOT NULL,
7377 id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
74- original_action_id uuid REFERENCES app.event_actions(id) ,
78+ original_action_id uuid,
7579 registration_number text UNIQUE,
7680 request_id text,
77- status app.action_status NOT NULL,
81+ status TEXT NOT NULL,
7882 transaction_id text NOT NULL,
7983 content jsonb,
8084 UNIQUE (id, event_id)
0 commit comments