Create schema and tables

--Drop existing VML schema if it exists in the database
DROP SCHEMA IF EXISTS vml CASCADE;
COMMIT;
 
--Create new VML schema
CREATE SCHEMA vml;
COMMIT;

--Create tha tables
CREATE TABLE "vml"."text" ( OGC_FID SERIAL, CONSTRAINT "text_pk" PRIMARY KEY (OGC_FID) );
SELECT AddGeometryColumn('vml','text','wkb_geometry',27700,'POINT',2);
ALTER TABLE "vml"."text" ADD COLUMN "fid" VARCHAR;
ALTER TABLE "vml"."text" ADD COLUMN "featurecode" INTEGER;
ALTER TABLE "vml"."text" ADD COLUMN "featuredescription" VARCHAR;
ALTER TABLE "vml"."text" ADD COLUMN "anchorposition" INTEGER;
ALTER TABLE "vml"."text" ADD COLUMN "font" INTEGER;
ALTER TABLE "vml"."text" ADD COLUMN "height" FLOAT8;
ALTER TABLE "vml"."text" ADD COLUMN "orientation" INTEGER;
ALTER TABLE "vml"."text" ADD COLUMN "orientdeg" FLOAT8;
ALTER TABLE "vml"."text" ADD COLUMN "textstring" VARCHAR;
COMMIT;

CREATE TABLE "vml"."line" ( OGC_FID SERIAL, CONSTRAINT "line_pk" PRIMARY KEY (OGC_FID) );
SELECT AddGeometryColumn('vml','line','wkb_geometry',27700,'LINESTRING',2);
ALTER TABLE "vml"."line" ADD COLUMN "fid" VARCHAR;
ALTER TABLE "vml"."line" ADD COLUMN "featurecode" INTEGER;
ALTER TABLE "vml"."line" ADD COLUMN "featuredescription" VARCHAR;
COMMIT;

CREATE TABLE "vml"."roadcline" ( OGC_FID SERIAL, CONSTRAINT "roadcline_pk" PRIMARY KEY (OGC_FID) );
SELECT AddGeometryColumn('vml','roadcline','wkb_geometry',27700,'LINESTRING',2);
ALTER TABLE "vml"."roadcline" ADD COLUMN "fid" VARCHAR;
ALTER TABLE "vml"."roadcline" ADD COLUMN "featurecode" INTEGER;
ALTER TABLE "vml"."roadcline" ADD COLUMN "featuredescription" VARCHAR;
ALTER TABLE "vml"."roadcline" ADD COLUMN "roadnumber" VARCHAR;
ALTER TABLE "vml"."roadcline" ADD COLUMN "roadname" VARCHAR;
COMMIT;

CREATE TABLE "vml"."area" ( OGC_FID SERIAL, CONSTRAINT "area_pk" PRIMARY KEY (OGC_FID) );
SELECT AddGeometryColumn('vml','area','wkb_geometry',27700,'POLYGON',2);
ALTER TABLE "vml"."area" ADD COLUMN "fid" VARCHAR;
ALTER TABLE "vml"."area" ADD COLUMN "featurecode" INTEGER;
ALTER TABLE "vml"."area" ADD COLUMN "featuredescription" VARCHAR;
COMMIT;

CREATE TABLE "vml"."vectormappoint" ( OGC_FID SERIAL, CONSTRAINT "vectormappoint_pk" PRIMARY KEY (OGC_FID) );
SELECT AddGeometryColumn('vml','vectormappoint','wkb_geometry',27700,'POINT',2);
ALTER TABLE "vml"."vectormappoint" ADD COLUMN "fid" VARCHAR;
ALTER TABLE "vml"."vectormappoint" ADD COLUMN "featurecode" INTEGER;
ALTER TABLE "vml"."vectormappoint" ADD COLUMN "featuredescription" VARCHAR;
ALTER TABLE "vml"."vectormappoint" ADD COLUMN "orientation" INTEGER;
ALTER TABLE "vml"."vectormappoint" ADD COLUMN "orientdeg" FLOAT8;
COMMIT;