create extension if not exists postgis cascade;

create extension if not exists "uuid-ossp";

create schema if not exists bs;

create table bs.simu (
  	id serial primary key,
	pid integer default 0,
	num integer,
  	name varchar(100),
  	data varchar(8000),
	status smallint default 0,
  	result varchar(1000),
	create_time timestamp(6) without time zone default now(),
	update_time timestamp(6) without time zone,
	bak varchar(2000)
);

comment on table bs.simu is '仿真表';
comment on column bs.simu.id is '主键ID';
comment on column bs.simu.pid is '父ID';
comment on column bs.simu.num is '序号';
comment on column bs.simu.name is '名称';
comment on column bs.simu.data is '数据(JSON)';
comment on column bs.simu.status is '状态：0-创建仿真，1-连接GEDB库，2-下载空间数据，3-下载高程数据，4-模拟内涝仿真，5-处理仿真数据，10-完成，-10-出错';
comment on column bs.simu.result is '结果';
comment on column bs.simu.create_time is '创建时间';
comment on column bs.simu.update_time is '更新时间';
comment on column bs.simu.bak is '备注';

-- insert into bs.simu (pid, num, name, data, status, result, bak) values (0, 1, '仿真01', null, 0, '', null);

select * from bs.simu;
