create schema if not exists desarrollo1;
set search_path to desarrollo1;

CREATE TABLE if not exists projects (
    "project_id" serial NOT NULL primary key,
    "project_name" character varying(50) NOT NULL
);

CREATE TABLE if not exists agencies (
    "id" bigserial not null primary key,
    "agency_id" character varying(50) NOT NULL,
    "agency_name" character varying(50) NOT NULL,
    "agency_url" character varying(200) NOT NULL,
    "agency_timezone" character varying(20) NOT NULL,
    "agency_lang" character varying(10),
    "agency_phone" character varying(20),
    "agency_fare_url" character varying(255),
    "agency_email" character varying(255),
    "project_id" integer NOT NULL references projects
);

CREATE TABLE if not exists routes (
    "id" bigserial not null primary key,
    "route_id" character varying(50) NOT NULL,
    "route_short_name" character varying(50),
    "route_long_name" character varying(200),
    "route_desc" character varying(50),
    "route_type" integer NOT NULL,
    "route_url" character varying(200),
    "route_color" character varying(10),
    "route_text_color" character varying(10),
    "agency_id" bigint NOT NULL references agencies (id)
);
