diff --git a/db/up/add_countries_regions_and_cities.sql b/db/up/add_countries_regions_and_cities.sql new file mode 100644 index 000000000..c1c51c34e --- /dev/null +++ b/db/up/add_countries_regions_and_cities.sql @@ -0,0 +1,8 @@ +create table cities (city varchar(255) not null, region varchar(2) not null, regionname varchar(64), countrycode varchar(2) not null, countryname varchar(64)); +insert into cities (city, region, countrycode) select distinct city, region, countrycode from geoiplocations where length(city) > 0 and length(countrycode) > 0; + +create table regions (region varchar(2) not null, regionname varchar(64), countrycode varchar(2) not null); +insert into regions (region, countrycode) select distinct region, countrycode from cities; + +create table countries (countrycode varchar(2) not null, countryname varchar(64)); +insert into countries (countrycode) select distinct countrycode from regions; diff --git a/db/up/connection_client_type.sql b/db/up/connection_client_type.sql index 17aabd21f..b38df8e9d 100644 --- a/db/up/connection_client_type.sql +++ b/db/up/connection_client_type.sql @@ -1 +1,3 @@ -ALTER TABLE connections ADD COLUMN client_type VARCHAR(256) NOT NULL; \ No newline at end of file +ALTER TABLE connections ADD COLUMN client_type VARCHAR(256); +UPDATE connections SET client_type = 'old' WHERE client_type IS NULL; +ALTER TABLE connections ALTER COLUMN client_type SET NOT NULL;