Skip to content

Commit

Permalink
Update sql init script
Browse files Browse the repository at this point in the history
  • Loading branch information
tarun-nil committed Jan 25, 2024
1 parent 93258ed commit d7de2fa
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions swift-activities/src/main/resources/db/migration/V1__init.sql
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
CREATE SCHEMA swift_activities;

CREATE TYPE swift_activities.activity_type AS ENUM('Running', 'Swimming', 'Cycling');

CREATE TABLE swift_activities.user_account (
user_id uuid NOT NULL,
user_name text NULL,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
name text NULL,
created_at timestamptz DEFAULT now(),
updated_at timestamptz DEFAULT now(),
CONSTRAINT user_account_pk PRIMARY KEY (user_id)
);

CREATE TABLE swift_activities.activity (
activity_id uuid NOT NULL,
user_id uuid NOT NULL,
activity_name text NULL,
activity_type swift_activities.activity_type NOT NULL,
user_id uuid,
name text NULL,
type swift_activities.activity_type NOT NULL,
start_time timestamptz NULL,
end_time timestamptz NULL,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
CONSTRAINT activity_pk PRIMARY KEY (activity_id),
CONSTRAINT activity_fk FOREIGN KEY (user_id) REFERENCES swift_activities.user_account(user_id)
created_at timestamptz DEFAULT now(),
updated_at timestamptz DEFAULT now(),
CONSTRAINT activity_pk PRIMARY KEY (activity_id)
);

CREATE TABLE swift_activities.activity_log (
activity_log_id serial NOT NULL,
CREATE TABLE swift_activities.activity_geolocation_data (
activity_geo_data_id serial NOT NULL,
activity_id uuid NOT NULL,
activity_stats json NOT NULL,
data json NOT NULL,
"timestamp" timestamptz NULL,
created_at timestamptz NOT NULL DEFAULT now(),
created_at timestamptz DEFAULT now(),
CONSTRAINT activity_log_pk PRIMARY KEY (activity_log_id),
CONSTRAINT activity_log_fk FOREIGN KEY (activity_id) REFERENCES swift_activities.activity(activity_id)
);

CREATE TABLE swift_activities.activity_insights (
activity_insight_id uuid NOT NULL,
activity_id uuid NOT NULL,
distance numeric NULL,
duration bigint NULL,
average_speed numeric NULL,
top_speed numeric NULL,
lowest_speed numeric NULL,
stats bytea NOT NULL,
created_at timestamptz DEFAULT now(),
CONSTRAINT activity_insights_pk PRIMARY KEY (activity_insight_id),
CONSTRAINT activity_insights_fk FOREIGN KEY (activity_id) REFERENCES swift_activities.activity(activity_id)
);
Expand Down

0 comments on commit d7de2fa

Please sign in to comment.