diff options
Diffstat (limited to 'service-person/migrations/2021-10-22-182006_create_initial_tables/up.sql')
-rw-r--r-- | service-person/migrations/2021-10-22-182006_create_initial_tables/up.sql | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/service-person/migrations/2021-10-22-182006_create_initial_tables/up.sql b/service-person/migrations/2021-10-22-182006_create_initial_tables/up.sql new file mode 100644 index 0000000..24a214f --- /dev/null +++ b/service-person/migrations/2021-10-22-182006_create_initial_tables/up.sql @@ -0,0 +1,34 @@ +-- Your SQL goes here + +CREATE TABLE countries ( + id SERIAL PRIMARY KEY NOT NULL, + name VARCHAR NOT NULL +); + +CREATE TABLE cities ( + id SERIAL PRIMARY KEY NOT NULL, + name VARCHAR NOT NULL +); + +CREATE TABLE streets ( + id SERIAL PRIMARY KEY NOT NULL, + name VARCHAR NOT NULL +); + +CREATE TABLE address ( + id SERIAL PRIMARY KEY NOT NULL, + + country_id INTEGER REFERENCES countries(id) NOT NULL, + city_id INTEGER REFERENCES cities(id) NOT NULL, + street_id INTEGER REFERENCES streets(id) NOT NULL, + + addr_number INTEGER NOT NULL +); + +CREATE TABLE persons ( + id SERIAL PRIMARY KEY NOT NULL, + name VARCHAR NOT NULL, + age INTEGER NOT NULL, + + address_id INTEGER REFERENCES address(id) NOT NULL +); |