Skip to content

Commit 6230fbf

Browse files
committed
modified the schema for better architecture
1 parent d6166cf commit 6230fbf

File tree

4 files changed

+51
-39
lines changed

4 files changed

+51
-39
lines changed

cli/macrostrat/cli/subsystems/user_features/saved_locations_schema.sql

Lines changed: 0 additions & 32 deletions
This file was deleted.

cli/macrostrat/cli/subsystems/user_features/update_saved_locations.sql

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATE OR REPLACE VIEW macrostrat_api.user_locations AS
2+
SELECT *
3+
FROM user_features.user_locations;
4+
5+
--this will change from web_anon to an authorized user once that workflow has been implemented.
6+
--web_anon is used for testing only right now.
7+
GRANT SELECT, INSERT, UPDATE, DELETE ON macrostrat_api.user_locations TO web_anon;
8+
9+
NOTIFY pgrst, 'reload schema';
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
CREATE SCHEMA user_features;
2+
3+
CREATE TYPE location_type AS ENUM ('Favorites', 'Want to go', 'Geological wonder');
4+
5+
create table user_locations
6+
(
7+
id serial
8+
primary key,
9+
user_id integer not null
10+
constraint fk_user
11+
references macrostrat_auth."user",
12+
name varchar(120) not null,
13+
description text,
14+
latitude numeric not null,
15+
longitude numeric not null,
16+
created_at timestamp default now() not null,
17+
updated_at timestamp default now() not null,
18+
category location_type,
19+
orientation_details text
20+
);
21+
22+
create table location_tags
23+
(
24+
id serial PRIMARY KEY,
25+
user_id integer not null constraint fk_user_id REFERENCES macrostrat_auth."user",
26+
location_id integer not null constraint fk_location_id REFERENCES user_features."user_locations",
27+
name varchar(120) not NULL,
28+
description text,
29+
color varchar(30)
30+
);
31+
32+
alter table user_locations
33+
owner to "macrostrat-admin";
34+
35+
grant delete, insert, select, update on user_locations to web_anon;
36+
37+
grant delete, insert, select, update on user_locations to web_user;
38+
39+
40+
41+
42+

0 commit comments

Comments
 (0)