sql/1.sql
changeset 13 23a242d7b7fa
parent 12 191b3c25974a
equal deleted inserted replaced
12:191b3c25974a 13:23a242d7b7fa
     1 --- vim: set noet nosta sw=4 ts=4 ft=sql:
     1 --- vim: set noet nosta sw=4 ts=4 ft=sql:
     2 BEGIN;
     2 BEGIN;
     3 
     3 
     4 DROP TABLE IF EXISTS requests;
     4 CREATE TABLE IF NOT EXISTS requests (
     5 CREATE TABLE requests (
     5 	scheme VARCHAR(5)   DEFAULT NULL,
     6 	hi INT,
     6 	host   VARCHAR(255) DEFAULT NULL,
       
     7 	tld    VARCHAR(255) DEFAULT NULL,
       
     8 	path   TEXT         DEFAULT NULL,
       
     9 	port   INTEGER      DEFAULT NULL,
       
    10 	ip     VARCHAR(72)  DEFAULT NULL,
       
    11 	user   VARCHAR(40)  DEFAULT NULL,
       
    12 	method VARCHAR(10)  DEFAULT NULL,
     7 	rewrite_rule INTEGER REFERENCES rewrite_rules( id ) ON DELETE SET NULL ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED 
    13 	rewrite_rule INTEGER REFERENCES rewrite_rules( id ) ON DELETE SET NULL ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED 
     8 );
    14 );
       
    15 CREATE INDEX IF NOT EXISTS host_idx ON requests ( host );
       
    16 CREATE INDEX IF NOT EXISTS tld_idx  ON requests ( tld );
       
    17 CREATE INDEX IF NOT EXISTS path_idx ON requests ( path );
     9 
    18 
    10 DROP TABLE IF EXISTS rewrite_rules;
    19 CREATE TABLE IF NOT EXISTS rewrite_rules (
    11 CREATE TABLE rewrite_rules (
    20 	id     INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    12 	id    INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    21 	scheme VARCHAR(5)   DEFAULT NULL,
    13 	redir TINYINT NOT NULL DEFAULT 0 CHECK( redir IN (0,1,2) )
    22 	host   VARCHAR(255) DEFAULT NULL,
       
    23 	path   TEXT         DEFAULT NULL,
       
    24 	port   INTEGER      DEFAULT NULL,
       
    25 	redir  TINYINT NOT NULL DEFAULT 0 CHECK( redir IN (0,1,2) )
    14 );
    26 );
    15 
    27 
    16 COMMIT;
    28 COMMIT;