if exists (select * from dbo.sysobjects where id = object_id(N'[QX_CHART]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [QX_CHART]
GO

create table dbo.QX_CHART (
    CHART_ID        INT             NOT NULL,
    NAME            VARCHAR(255)    NOT NULL,
    OWNER_ID        INT,
    PUBLIC_CHART    NUMERIC(2)      NOT NULL  DEFAULT 0,
    SYSTEM_CHART    NUMERIC(2)      NOT NULL  DEFAULT 0,
    TIMESTAMP       DATETIME        NOT NULL,
    BODY            TEXT            NOT NULL,
    constraint PK_QX_CHART primary key (CHART_ID)
)
go

create index IDX_QX_CHART_OWNER         on dbo.QX_CHART (OWNER_ID)
create index IDX_QX_CHART_PUBLIC_CHART on dbo.QX_CHART (PUBLIC_CHART)
create index IDX_QX_CHART_SYSTEM_CHART on dbo.QX_CHART (SYSTEM_CHART)
go

UPDATE QX_SYS_PROP SET PROP_VAL = '062' WHERE (PROP_ID = 'DB_CORE_VERSION');
go
