bus.fey.ink/sql/create-tables.sql

63 lines
984 B
SQL

--- Create tables for gtfs information
PRAGMA trusted_schema=1;
CREATE TABLE stops (
id TEXT PRIMARY KEY,
name TEXT,
code TEXT,
description TEXT,
platform TEXT,
parent TEXT
);
SELECT InitSpatialMetaData();
SELECT AddGeometryColumn(
'stops',
'location',
25832,
'POINT',
'XY'
);
SELECT CreateSpatialIndex('stops', 'location');
CREATE TABLE routes (
id TEXT PRIMARY KEY,
short_name TEXT,
long_name TEXT,
description TEXT,
type INTEGER,
color INTEGER,
text_color INTEGER
);
CREATE TABLE trips (
id TEXT PRIMARY KEY,
route_id TEXT,
service_id TEXT,
headsign TEXT,
short_name TEXT
);
CREATE TABLE stop_times (
trip_id TEXT,
sequence INTEGER,
arrival TEXT,
departure TEXT,
stop_id TEXT,
PRIMARY KEY(trip_id, sequence)
);
CREATE TABLE calendar (
service TEXT PRIMARY KEY,
days INTEGER NOT NULL,
start_date TEXT NOT NULL,
end_date TEXT NOT NULL
);
CREATE TABLE calendar_dates (
service TEXT,
date TEXT,
type INTEGER,
PRIMARY KEY(service, date)
);