BEGIN;
CREATE TABLE IF NOT EXISTS "BackupJobs" ("id"  PRIMARY KEY  NOT NULL  UNIQUE , 
										"name" TEXT NOT NULL , 
										"options" TEXT, 
										"repository_id" TEXT NOT NULL );
CREATE TABLE IF NOT EXISTS "BackupPoints" ("id"  PRIMARY KEY  NOT NULL  UNIQUE , 
											"link_id"  NOT NULL, 
											"creation_time" DATETIME NOT NULL , 
											"alg" INTEGER NOT NULL , 
											"backup_id" );
CREATE TABLE IF NOT EXISTS "BackupRepositories" ("id"  PRIMARY KEY  NOT NULL  UNIQUE , 
												"vbr_server_id" TEXT,
												"name" TEXT NOT NULL , 
												"type" INTEGER NOT NULL , 
												"path" TEXT NOT NULL );
CREATE TABLE IF NOT EXISTS "BackupStorages" ("id"  PRIMARY KEY  NOT NULL  UNIQUE , 
											"name" TEXT, 
											"in_repository_path" TEXT NOT NULL, 
											"backup_id" , 
											"creation_time" DATETIME NOT NULL, 
											"block_size" INTEGER NOT NULL, 
											"stat" TEXT );
CREATE TABLE IF NOT EXISTS "Backups" ("id"  PRIMARY KEY  NOT NULL  UNIQUE , 
										"creation_time" DATETIME NOT NULL , 
										"job_name" TEXT NOT NULL , 
										"job_id" , 
										"file_name" TEXT );
CREATE TABLE IF NOT EXISTS "ObjectsInBackups" ("id"  PRIMARY KEY  NOT NULL  UNIQUE , 
												"point_id"  NOT NULL , 
												"storage_id"  NOT NULL , 
												"prev_oib_id"  NOT NULL , 
												"name" TEXT, 
												"is_consistent" BOOL NOT NULL , 
												"is_corrupted" BOOL NOT NULL , 
												"inside_dir" TEXT NOT NULL , 
												"creation_time" DATETIME NOT NULL , 
												"alg" INTEGER NOT NULL, 
												"guest_info" TEXT NOT NULL );
CREATE TABLE IF NOT EXISTS "ObjectsInJobs" ("id"  PRIMARY KEY  NOT NULL  UNIQUE , 
											"job_id" NOT NULL , 
											"rec_type" INTEGER NOT NULL , 
											"obj_type" INTEGER NOT NULL , 
											"value" TEXT NOT NULL );
CREATE TABLE IF NOT EXISTS "JobSessions" ("id"  PRIMARY KEY  NOT NULL  UNIQUE ,									 
											"job_id" , 
											"type" INTEGER , 
											"start_time" DATETIME , 
											"end_time" DATETIME , 
											"state" INTEGER , 
											"state_changed" DATETIME , 
											"log_text" ,
											"logs_dir" TEXT,
											"progress" INTEGER,
											"progress_details" TEXT, 
											"details" TEXT );
CREATE TABLE IF NOT EXISTS "VbrServers" ("id" PRIMARY KEY  NOT NULL  UNIQUE ,
											"name" TEXT NOT NULL ,
											"endpoint" TEXT NOT NULL ,
											"fingerprint" TEXT);
COMMIT;
