Skip to content

Commit

Permalink
Merge pull request #15 from sve2-2020ss/fix/db-schema
Browse files Browse the repository at this point in the history
fix db schema primary key
  • Loading branch information
agentS authored Apr 27, 2020
2 parents b32dbba + 4f7fd2c commit dc67950
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions _db/create.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
DROP TABLE measurement;
DROP TABLE station;

CREATE TABLE station(
id SERIAL PRIMARY KEY NOT NULL,
name varchar(255) NOT NULL
);

CREATE TABLE measurement(
station_id SERIAL NOT NULL,
station_id INTEGER NOT NULL,
temperature DOUBLE PRECISION NOT NULL,
humidity DOUBLE PRECISION NOT NULL,
air_pressure DOUBLE PRECISION NOT NULL,
Expand All @@ -13,12 +16,15 @@ CREATE TABLE measurement(
CONSTRAINT pk_measurement PRIMARY KEY(station_id, created_at)
);

INSERT INTO station (id, name) VALUES (1, 'station1');
INSERT INTO station (id, name) VALUES (2, 'station2');
INSERT INTO station (id, name) VALUES (3, 'station3');
INSERT INTO station (id, name) VALUES (4, 'station4');
INSERT INTO station (id, name) VALUES (5, 'station5');
INSERT INTO station (id, name) VALUES (6, 'station6');
INSERT INTO station (id, name) VALUES (10, 'ESP8266-powered weather station');
INSERT INTO station (name) VALUES ('station1');
INSERT INTO station (name) VALUES ('station2');
INSERT INTO station (name) VALUES ('station3');
INSERT INTO station (name) VALUES ('station4');
INSERT INTO station (name) VALUES ('station5');
INSERT INTO station (name) VALUES ('station6');
INSERT INTO station (name) VALUES ('station7');
INSERT INTO station (name) VALUES ('station8');
INSERT INTO station (name) VALUES ('station9');
INSERT INTO station (name) VALUES ('ESP8266-powered weather station');

COMMIT;

0 comments on commit dc67950

Please sign in to comment.