-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
103 changed files
with
2,859 additions
and
2,691 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS province; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CREATE TABLE IF NOT EXISTS province ( | ||
id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY, | ||
name TEXT CONSTRAINT name_length CHECK ( char_length(name) <= 120) NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS town; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE TABLE IF NOT EXISTS town ( | ||
id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY, | ||
province_id BIGINT NOT NULL REFERENCES province(id), | ||
name TEXT CONSTRAINT name_length CHECK ( char_length(name) <= 60) NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS street; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE TABLE IF NOT EXISTS street ( | ||
id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY, | ||
town_id BIGINT NOT NULL REFERENCES town(id), | ||
name TEXT CONSTRAINT name_length CHECK ( char_length(name) <= 120) NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS house_name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE TABLE IF NOT EXISTS house_name ( | ||
id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY, | ||
street_id BIGINT NOT NULL REFERENCES street(id), | ||
name TEXT CONSTRAINT name_length CHECK ( char_length(name) <= 40) NOT NULL | ||
); |
2 changes: 1 addition & 1 deletion
2
db/migrations/000009_building.down.sql → db/migrations/000013_address.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
DROP TABLE IF EXISTS building; | ||
DROP TABLE IF EXISTS address; | ||
DROP EXTENSION IF EXISTS postgis; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
CREATE EXTENSION IF NOT EXISTS postgis; | ||
|
||
CREATE TABLE IF NOT EXISTS address ( | ||
id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY, | ||
address_point GEOGRAPHY(Point, 4326) NOT NULL UNIQUE, | ||
house_name_id BIGINT NOT NULL REFERENCES house_name(id), | ||
metro TEXT CONSTRAINT metro_length CHECK ( char_length(metro) <= 120) NOT NULL | ||
); | ||
|
||
INSERT INTO province (name) VALUES ('California'); | ||
INSERT INTO province (name) VALUES ('New York'); | ||
|
||
-- Inserting into town table | ||
INSERT INTO town (province_id, name) VALUES (1, 'Los Angeles'); | ||
INSERT INTO town (province_id, name) VALUES (1, 'San Francisco'); | ||
INSERT INTO town (province_id, name) VALUES (2, 'New York City'); | ||
INSERT INTO town (province_id, name) VALUES (2, 'Buffalo'); | ||
|
||
-- Inserting into street table | ||
INSERT INTO street (town_id, name) VALUES (1, 'Sunset Boulevard'); | ||
INSERT INTO street (town_id, name) VALUES (1, 'Hollywood Boulevard'); | ||
INSERT INTO street (town_id, name) VALUES (2, 'Lombard Street'); | ||
INSERT INTO street (town_id, name) VALUES (3, 'Broadway'); | ||
INSERT INTO street (town_id, name) VALUES (4, 'Main Street'); | ||
|
||
-- Inserting into house_name table | ||
INSERT INTO house_name (street_id, name) VALUES (1, '1234'); | ||
INSERT INTO house_name (street_id, name) VALUES (1, '5678'); | ||
INSERT INTO house_name (street_id, name) VALUES (2, '4321'); | ||
INSERT INTO house_name (street_id, name) VALUES (3, '9876'); | ||
INSERT INTO house_name (street_id, name) VALUES (4, '6543'); | ||
|
||
-- Inserting into address table with a test value for address_point | ||
INSERT INTO address (address_point, house_name_id, metro) VALUES (ST_GeographyFromText('POINT(-118.2437 34.0522)'), 1, 'Metro Station A'); | ||
INSERT INTO address (address_point, house_name_id, metro) VALUES (ST_GeographyFromText('POINT(-122.4194 37.7749)'), 2, 'Metro Station B'); | ||
INSERT INTO address (address_point, house_name_id, metro) VALUES (ST_GeographyFromText('POINT(-122.4313 37.8044)'), 3, 'Metro Station C'); | ||
INSERT INTO address (address_point, house_name_id, metro) VALUES (ST_GeographyFromText('POINT(-73.9352 40.7306)'), 4, 'Metro Station D'); | ||
INSERT INTO address (address_point, house_name_id, metro) VALUES (ST_GeographyFromText('POINT(-78.8784 42.8864)'), 5, 'Metro Station E'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS building; |
5 changes: 1 addition & 4 deletions
5
db/migrations/000009_building.up.sql → db/migrations/000014_building.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
migrations/000014_question.up.sql → db/migrations/000019_question.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
migrations/000015_question_answer.up.sql → db/migrations/000020_question_answer.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.