PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE "user" ("id" INTEGER PRIMARY KEY  NOT NULL ,"password" VARCHAR(128),"name" VARCHAR(128) UNIQUE,"pin" VARCHAR(10), "firstname" VARCHAR(255), "lastname" VARCHAR(255), "email" VARCHAR(255), "extension" VARCHAR(10));
CREATE TABLE "cdr" ("id" INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL , "address" VARCHAR NOT NULL , "billid" VARCHAR NOT NULL , "billtime" VARCHAR NOT NULL , "called" VARCHAR NOT NULL , "caller" VARCHAR NOT NULL , "cdrid" INTEGER NOT NULL , "chan" VARCHAR NOT NULL , "direction" VARCHAR NOT NULL , "duration" VARCHAR NOT NULL , "external" VARCHAR NOT NULL , "reason" VARCHAR NOT NULL , "operation" VARCHAR NOT NULL , "ringtime" VARCHAR NOT NULL , "runid" INTEGER NOT NULL , "status" VARCHAR NOT NULL , "time" VARCHAR NOT NULL );
CREATE TABLE "sysconfig" ("id" INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL  UNIQUE , "key" VARCHAR(80), "value" VARCHAR(255) NOT NULL );
CREATE TABLE "phones" ("id" INTEGER PRIMARY KEY  NOT NULL ,"type" VARCHAR(30) NOT NULL ,"mac_addr" VARCHAR(14) NOT NULL ,"nobody_index" INTEGER(8) NOT NULL ,"added" INTEGER(10) NOT NULL ,"firmware" VARCHAR(25) NOT NULL ,"fw_manual_update" INTEGER(1) NOT NULL ,"sip_account_id" INTEGER(10) NOT NULL );
CREATE TABLE "sip_accounts" ("id" integer PRIMARY KEY NOT NULL ,"authname" varchar(255) NOT NULL ,"subnet" varchar(255),"secret" varchar(40) NOT NULL ,"current_ip" varchar(16),"device_name" varchar(64) ,"location" varchar(255) ,"last_contact" timestamp ,"expires" integer ,"state" varchar(10), "user_id" INTEGER);
CREATE TABLE "groups" ("id" INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL  UNIQUE , "type" VARCHAR(20) NOT NULL , "name" VARCHAR(40) NOT NULL , "title" VARCHAR(40) NOT NULL , "description" VARCHAR(255));
CREATE TABLE "calllist" ("id" INTEGER PRIMARY KEY NOT NULL , "calluuid" VARCHAR(100) NOT NULL , "timestamp" VARCHAR NOT NULL DEFAULT CURRENT_TIMESTAMP, "user" VARCHAR(20) NOT NULL , "remotecid" VARCHAR(255) NOT NULL , "duration" INTEGER(10) DEFAULT NULL, "state" INTEGER(3) DEFAULT 0, "type" INTEGER(3) DEFAULT 0, "meta" VARCHAR(255) NOT NULL , "hidden" INTEGER(1) DEFAULT 0, "comment" VARCHAR(255) NOT NULL );
CREATE TABLE "gateway" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "name" VARCHAR(255) NOT NULL , "host" VARCHAR(255), "authname" VARCHAR(255), "secret" VARCHAR(255), "current_ip" VARCHAR(16), "device_name" VARCHAR(64), "expires" INTEGER, "typ" VARCHAR(10) NOT NULL , "state" VARCHAR(10), "inc_called_field" VARCHAR(20), "inc_called_search" VARCHAR(255), "inc_called_replace" VARCHAR(255));
DELETE FROM sqlite_sequence;
COMMIT;
