Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL updates for the planes table #1211

Merged
merged 3 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sql/clean-duplicate-planes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ select name, min(plid), max(plid), count(*) as dupes from planes GROUP BY name h

-- Find exact dupes
drop table if exists tmp_planes_duplicates;
create table tmp_planes_duplicates (plid int, duplicate_of int)
create table tmp_planes_duplicates (plid int, duplicate_of int);
insert into tmp_planes_duplicates
select p1.plid, min(p2.plid) as duplicate_of
from planes p1, planes p2
Expand Down
10 changes: 8 additions & 2 deletions sql/create.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
DROP DATABASE IF EXISTS flightdb2;
chrisrosset marked this conversation as resolved.
Show resolved Hide resolved
CREATE DATABASE flightdb2;

DROP USER IF EXISTS openflights@localhost;
chrisrosset marked this conversation as resolved.
Show resolved Hide resolved
CREATE USER openflights@localhost;
GRANT ALL PRIVILEGES ON flightdb2.* TO openflights@localhost;

Expand Down Expand Up @@ -155,12 +157,16 @@ CREATE TABLE `locales` (

DROP TABLE IF EXISTS `planes`;
CREATE TABLE `planes` (
`name` text,
`name` varchar(80),
`abbr` text,
`speed` double default NULL,
`plid` int(11) NOT NULL auto_increment,
`public` char(1) default NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default 'n'?

PRIMARY KEY (`plid`)
`iata` text default NULL,
`icao` text default NULL,
`frequency` int default 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this should be int(11) to match the live schema

PRIMARY KEY (`plid`),
UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `routes`;
Expand Down
8 changes: 8 additions & 0 deletions sql/load-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(name, iso_code, dafif_code);

\! echo Importing planes...
LOAD DATA LOCAL INFILE 'data/planes.dat'
REPLACE INTO TABLE planes
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(name, iata, icao);

\! echo Importing locales...

LOAD DATA LOCAL INFILE 'locale/locales.dat'
Expand Down