-- generator on mysql
SET SESSION group_concat_max_len = 16500;
select 
--    c.TABLE_NAME,
    concat(
        'create table [',
        c.TABLE_NAME,
        '] (',
        group_concat(
            concat(
                '[',
                c.COLUMN_NAME, 
                '] ',
                case c.DATA_TYPE
                    when 'char' then concat('nchar(', c.CHARACTER_MAXIMUM_LENGTH, ')')
                    when 'varchar' then concat('nvarchar(', c.CHARACTER_MAXIMUM_LENGTH, ')')
                    when 'text' then 'nvarchar(max)'
                    when 'mediumtext' then 'nvarchar(max)'
                    when 'mediumblob' then 'varbinary(max)'
                    when 'enum' then concat('nvarchar(100)')
                    else c.DATA_TYPE
                end,
                ' ',
                if(c.IS_NULLABLE = 'NO', 'not null', 'null'),
                if(
                    c.EXTRA != 'auto_increment' and c.COLUMN_DEFAULT is not null, 
                    concat(
                        ' default ', 
                        if(
                            c.DATA_TYPE in ('int', 'float'),
                            c.COLUMN_DEFAULT,
                            concat('\'', c.COLUMN_DEFAULT, '\'')
                        ),
                        ' '
                    ), 
                    ''
                ),
                if(c.DATA_TYPE = 'int' and c.EXTRA = 'auto_increment', ' identity(1,1) ', ' '),
                if(c.DATA_TYPE = 'enum', concat(' check([', c.COLUMN_NAME, '] in ', substring(c.COLUMN_TYPE, 5), ' or [', c.COLUMN_NAME, '] = \'\') '), '')
            )
            order by c.ORDINAL_POSITION
            separator ', '
        ),
        if(
            pr.primaries is not null,
            concat(
                ', primary key(',
                pr.primaries,
                ')'
            ),
            ''
        ),
        ');'
    )
from INFORMATION_SCHEMA.COLUMNS c
left join (
    select 
        pri.TABLE_SCHEMA, 
        pri.TABLE_NAME,
        group_concat(concat('[', pri.COLUMN_NAME, ']') order by pri.ORDINAL_POSITION separator ', ') primaries
    from INFORMATION_SCHEMA.COLUMNS pri 
    where pri.TABLE_SCHEMA = 'prj_carleyfoundry_import'
        and pri.COLUMN_KEY = 'PRI'
    group by pri.TABLE_SCHEMA, pri.TABLE_NAME
) pr on pr.TABLE_SCHEMA = c.TABLE_SCHEMA and pr.TABLE_NAME = c.TABLE_NAME
where c.TABLE_SCHEMA = 'prj_carleyfoundry_import'
group by c.TABLE_SCHEMA, c.TABLE_NAME



-- generated on mssql
/*
create table [cf_AclResource] ([id] int not null identity(1,1) , [title] nvarchar(255) not null default ''  , [query] nvarchar(255) not null default ''  , [message] nvarchar(max) not null , [sorter] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_AclResource2Role] ([idAclResource] int not null default 0  , [idAclRole] nvarchar(100) not null default 'admin'   check([idAclRole] in ('admin','user','guest') or [idAclRole] = '') , primary key([idAclResource], [idAclRole]));
create table [cf_AclResourcePrivilege] ([idAclResource] int not null default 0  , [name] nvarchar(255) not null default ''  , [title] nvarchar(255) not null default ''  , [sorter] int not null default 0  , primary key([idAclResource], [name]));
create table [cf_AclRole] ([id] nvarchar(100) not null default 'admin'   check([id] in ('admin','user','guest') or [id] = '') , [title] nvarchar(255) not null default ''  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_AclRule] ([id] int not null identity(1,1) , [idAclRole] nvarchar(100) not null default 'admin'   check([idAclRole] in ('admin','user','guest') or [idAclRole] = '') , [idRole] int not null default 0  , [idAclResource] int not null default 0  , [privilege] nvarchar(255) null , [type] nvarchar(100) not null default 'allow'   check([type] in ('allow','deny') or [type] = '') , [sorter] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_Client] ([id] int not null identity(1,1) , [number] nvarchar(255) not null default ''   unique , [name] nvarchar(255) not null default ''  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_Client2User] ([id] int not null identity(1,1) , [clientId] int not null default 0  , [userId] int not null default 0  , primary key([id]));
create table [cf_Department] ([id] int not null identity(1,1) , [parentId] int not null default 0  , [name] nvarchar(255) not null default ''  , [sorter] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_DepartmentAndProcessSorter] ([id] int not null identity(1,1) , [departmentId] int null , [processId] int null , [sorter] int not null default 0  , primary key([id]));
create table [cf_DPermission] ([id] int not null default 0  , [title] nvarchar(255) not null default ''  , [resourceId] int not null default 0  , [privilegeId] int not null default 0  , primary key([id]));
create table [cf_DPrivilege] ([id] int not null default 0  , [name] nvarchar(255) not null default ''  , primary key([id]));
create table [cf_DResource] ([id] int not null default 0  , [name] nvarchar(255) not null default ''  , primary key([id]));
create table [cf_DState] ([id] nvarchar(2) not null default ''  , [title] nvarchar(255) not null default ''  , primary key([id]));
create table [cf_DStatus] ([id] nvarchar(15) not null default ''  , [title] nvarchar(55) not null default ''  , primary key([id]));
create table [cf_Form] ([id] int not null identity(1,1) , [blockedBy] int not null default 0  , [blockedAt] datetime null , [height] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_FormElement] ([id] int not null identity(1,1) , [formId] int not null default 0  , [formType] nvarchar(100) not null default 'process'   check([formType] in ('process','part') or [formType] = '') , [typeId] int not null default 0  , [left] int not null default 0  , [top] int not null default 0  , [zIndex] int not null default 0  , [draftFor] int null , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_FormElementProperty] ([id] int not null identity(1,1) , [elementTypeId] int not null default 0  , [label] nvarchar(255) not null default ''  , [alias] nvarchar(255) not null default ''  , [type] nvarchar(100) not null default 'text'   check([type] in ('text','textarea','select','checkbox') or [type] = '') , [options] nvarchar(max) not null , [sorter] int not null default 0  , primary key([id]));
create table [cf_FormElementPropertyValue] ([elementId] int not null default 0  , [propertyId] int not null default 0  , [value] nvarchar(max) not null , primary key([elementId], [propertyId]));
create table [cf_FormSubmission] ([id] int not null identity(1,1) , [formId] int not null default 0  , [formType] nvarchar(100) not null default 'process'   check([formType] in ('process','part') or [formType] = '') , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_FormSubmissionValue] ([id] int not null identity(1,1) , [submissionId] int not null default 0  , [elementId] int not null default 0  , [value] nvarchar(max) null , primary key([id]));
create table [cf_Media] ([id] int not null identity(1,1) , [processId] int not null default 0  , [partId] int not null default 0  , [revisionStart] int null , [revisionEnd] int null , [title] nvarchar(255) not null default ''  , [description] nvarchar(max) not null , [type] nvarchar(100) not null default 'image'   check([type] in ('image','video') or [type] = '') , [image] nvarchar(255) null , [video] nvarchar(255) null , [sorter] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_Part] ([id] int not null identity(1,1) , [blockedVersion] int null default 0  , [blockedBy] int not null default 0  , [blockedAt] datetime null , [height] int not null default 300  , [defaultProcessId] int not null default 0  , [currentVersion] int not null default 0  , [sorter] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_Part2PartData] ([id] int not null identity(1,1) , [partId] int not null default 0  , [versionId] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_Part2Process] ([partId] int not null default 0  , [processId] int not null default 0  );
create table [cf_Part2ProcessData] ([id] int not null identity(1,1) , [processId] int not null default 0  , [versionId] int not null default 0  , [setId] int null , [revisionEnd] int null , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_Part2User] ([id] int not null identity(1,1) , [partId] int not null default 0  , [userId] int not null default 0  , primary key([id]));
create table [cf_PartVersion] ([id] int not null identity(1,1) , [partId] int not null default 0  , [preProduction] nvarchar(100) not null default 'y'   check([preProduction] in ('y','n') or [preProduction] = '') , [version] int not null default 0  , [number] nvarchar(255) not null default ''  , [name] nvarchar(255) not null default ''  , [clientId] int not null default 0  , [weight] float not null default 0  , [alloyTemper] nvarchar(255) not null default ''  , [status] nvarchar(255) not null default ''  , [localDirectory] nvarchar(255) not null default ''  , [image] nvarchar(255) null , [comments] nvarchar(max) not null , [userId] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_Process] ([id] int not null identity(1,1) , [departmentId] int not null default 0  , [name] nvarchar(255) not null default ''  , [isMedia] nvarchar(100) not null default 'n'   check([isMedia] in ('n','y') or [isMedia] = '') , [isMultiply] nvarchar(100) not null default 'n'   check([isMultiply] in ('n','y') or [isMultiply] = '') , [sorter] int not null default 0  , [blockedBy] int not null default 0  , [blockedAt] datetime null , [height] int not null default 0  , [sidebar] nvarchar(255) not null default ''  , [new] nvarchar(100) not null default 'y'   check([new] in ('y','n') or [new] = '') , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_Process2User] ([id] int not null identity(1,1) , [processId] int not null default 0  , [userId] int not null default 0  , primary key([id]));
create table [cf_User] ([id] int not null identity(1,1) , [firstName] nvarchar(255) not null default ''  , [lastName] nvarchar(255) not null default ''  , [login] nvarchar(255) null , [email] nvarchar(128) not null default ''   unique , [password] nvarchar(255) not null default ''  , [salt] nvarchar(8) not null default ''  , [autologinCode] nvarchar(32) null , [newPassword] nvarchar(32) null , [newSalt] nvarchar(8) null , [recoverCode] nvarchar(32) null  unique , [recoverCodeExpirationDate] datetime null , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_User2Department] ([userId] int not null default 0  , [departmentId] int not null default 0  );
create table [cf_User2Permission] ([userId] int not null default 0  , [permissionId] int not null default 0  );
create table [cf_zz_Admin] ([id] int not null identity(1,1) , [firstName] nvarchar(255) not null default ''  , [middleInitial] nchar(1) not null default ''  , [lastName] nvarchar(255) not null default ''  , [login] nvarchar(50) not null default ''   unique , [password] nvarchar(32) not null default ''  , [salt] nvarchar(8) not null default ''  , [autologinCode] nvarchar(32) null  unique , [remoteAuthEnabled] nvarchar(100) not null default 'n'   check([remoteAuthEnabled] in ('n','y') or [remoteAuthEnabled] = '') , [remotePasswordExpirationDate] datetime null , [email] nvarchar(255) null  unique , [stsLoginCode] nvarchar(32) null , [stsLoginEnabled] nvarchar(100) not null default 'n'   check([stsLoginEnabled] in ('n','y') or [stsLoginEnabled] = '') , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_DFileType] ([extension] nvarchar(8) not null default ''  , [type] nvarchar(255) not null default ''  , primary key([extension]));
create table [cf_zz_DLanguage] ([name] nvarchar(3) not null default ''  , [title] nvarchar(255) not null default ''  , [shortTitle] nvarchar(255) not null default ''  , [icon] nvarchar(64) not null default ''  , [locale] nvarchar(16) not null default ''  , [def] nvarchar(100) not null default 'n'   check([def] in ('y','n') or [def] = '') , [enabled] nvarchar(100) not null default 'y'   check([enabled] in ('y','n') or [enabled] = '') , [sorter] int not null default 0  , primary key([name]));
create table [cf_zz_DNotFoundMode] ([id] int not null default 0  , [title] nvarchar(255) not null default ''  , [sorter] int not null default 0  , primary key([id]));
create table [cf_zz_DPageHandler] ([name] nvarchar(64) not null default ''  , [title] nvarchar(max) not null , [sorter] int not null default 0  , primary key([name]));
create table [cf_zz_DPageItemGroup] ([id] int not null identity(1,1) , [name] nvarchar(255) not null default ''  , [title] nvarchar(255) not null default ''  , [sorter] int not null default 0  , primary key([id]));
create table [cf_zz_DPageItemType] ([id] int not null identity(1,1) , [type] nvarchar(64) not null default ''   unique , [title] nvarchar(255) not null default ''  , [sorter] int not null default 0  , primary key([id]));
create table [cf_zz_DPageOption] ([name] nvarchar(32) not null default ''  , [title] nvarchar(255) not null default ''  , [show] nvarchar(100) not null default 'n'   check([show] in ('n','y') or [show] = '') , [value] nvarchar(100) not null default 'n'   check([value] in ('n','y') or [value] = '') , [sorter] int not null default 0  , primary key([name]));
create table [cf_zz_DraftHtmlBlock] ([id] int not null identity(1,1) , [added] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_DraftHtmlBlockContent] ([idBlock] int not null default 0  , [language] nvarchar(3) not null default ''  , [content] nvarchar(max) not null , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([idBlock], [language]));
create table [cf_zz_DraftPage] ([id] int not null default 0  , [idParent] int not null default 0  , [alias] nvarchar(255) null , [handler] nvarchar(64) not null default 'site'  , [bodyTemplate] nvarchar(255) not null default 'default.tpl'  , [showInSiteMap] nvarchar(100) not null default 'y'   check([showInSiteMap] in ('y','n') or [showInSiteMap] = '') , [showInMenu] nvarchar(100) not null default 'y'   check([showInMenu] in ('y','n') or [showInMenu] = '') , [allowDelete] nvarchar(100) not null default 'y'   check([allowDelete] in ('y','n') or [allowDelete] = '') , [isSecure] nvarchar(100) not null default 'n'   check([isSecure] in ('n','y') or [isSecure] = '') , [isIndexing] nvarchar(100) not null default 'y'   check([isIndexing] in ('y','n') or [isIndexing] = '') , [isRoot] nvarchar(100) not null default 'n'   check([isRoot] in ('n','y') or [isRoot] = '') , [hasBlocks] nvarchar(100) not null default 'n'   check([hasBlocks] in ('n','y') or [hasBlocks] = '') , [final] nvarchar(100) not null default 'n'   check([final] in ('n','y') or [final] = '') , [system] nvarchar(100) not null default 'n'   check([system] in ('n','y') or [system] = '') , [redirect] nvarchar(100) not null default 'n'   check([redirect] in ('n','y') or [redirect] = '') , [redirectType] nvarchar(100) null  check([redirectType] in ('page','url') or [redirectType] = '') , [redirectPageId] int not null default 0  , [redirectStatus] int not null default 302  , [redirectAlias] nvarchar(255) not null default ''  , [sorter] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_DraftPageContent] ([idPage] int not null default 0  , [language] nvarchar(3) not null default ''  , [title] nvarchar(255) not null default ''  , [menuTitle] nvarchar(255) not null default ''  , [header] nvarchar(max) not null , [keywords] nvarchar(max) not null , [description] nvarchar(max) not null , primary key([idPage], [language]));
create table [cf_zz_DraftPageItem] ([id] int not null identity(1,1) , [idPage] int not null default 0  , [idGroup] int not null default 1  , [type] nvarchar(64) not null default ''  , [number] int null , [name] nvarchar(255) null , [title] nvarchar(255) not null default ''  , [allowDelete] nvarchar(100) not null default 'y'   check([allowDelete] in ('y','n') or [allowDelete] = '') , [sorter] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_DraftPageItemConfig] ([id] int not null identity(1,1) , [idItem] int not null default 0  , [name] nvarchar(255) not null default ''  , [value] nvarchar(max) null , primary key([id]));
create table [cf_zz_DraftPageOption] ([id] int not null identity(1,1) , [idPage] int not null default 0  , [name] nvarchar(50) not null default ''  , [show] nvarchar(100) not null default 'n'   check([show] in ('n','y') or [show] = '') , [value] nvarchar(100) not null default 'n'   check([value] in ('n','y') or [value] = '') , primary key([id]));
create table [cf_zz_File] ([id] int not null identity(1,1) , [name] nvarchar(255) not null default ''  , [nameFs] nvarchar(255) not null default ''   unique , [type] nvarchar(255) not null default ''  , [size] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_HtmlBlock] ([id] int not null identity(1,1) , [added] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_HtmlBlockContent] ([idBlock] int not null default 0  , [language] nvarchar(3) not null default ''  , [content] nvarchar(max) not null , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([idBlock], [language]));
create table [cf_zz_Log] ([id] int not null identity(1,1) , [priority] nvarchar(100) not null default 'EMERG'   check([priority] in ('EMERG','ALERT','CRIT','ERR','WARN','NOTICE','INFO','DEBUG') or [priority] = '') , [ip] nvarchar(15) not null default ''  , [idSession] nvarchar(32) null , [serverName] nvarchar(255) not null default ''  , [url] nvarchar(255) not null default ''  , [message] nvarchar(max) not null , [backtrace] varbinary(max) null , [added] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_NotFound] ([id] int not null identity(1,1) , [modeId] int null , [isAjax] nvarchar(100) not null default 'n'   check([isAjax] in ('y','n') or [isAjax] = '') , [request] nvarchar(255) not null default ''  , [referer] nvarchar(255) not null default ''  , [userAgent] nvarchar(255) not null default ''  , [ipAddress] nvarchar(25) not null default ''  , [added] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_Page] ([id] int not null identity(1,1) , [idParent] int not null default 0  , [alias] nvarchar(255) null , [handler] nvarchar(64) not null default 'site'  , [bodyTemplate] nvarchar(255) not null default 'default.tpl'  , [showInSiteMap] nvarchar(100) not null default 'y'   check([showInSiteMap] in ('y','n') or [showInSiteMap] = '') , [showInMenu] nvarchar(100) not null default 'y'   check([showInMenu] in ('y','n') or [showInMenu] = '') , [allowDelete] nvarchar(100) not null default 'y'   check([allowDelete] in ('y','n') or [allowDelete] = '') , [isSecure] nvarchar(100) not null default 'n'   check([isSecure] in ('n','y') or [isSecure] = '') , [isIndexing] nvarchar(100) not null default 'y'   check([isIndexing] in ('y','n') or [isIndexing] = '') , [isRoot] nvarchar(100) not null default 'n'   check([isRoot] in ('n','y') or [isRoot] = '') , [hasBlocks] nvarchar(100) not null default 'n'   check([hasBlocks] in ('n','y') or [hasBlocks] = '') , [final] nvarchar(100) not null default 'n'   check([final] in ('n','y') or [final] = '') , [system] nvarchar(100) not null default 'n'   check([system] in ('n','y') or [system] = '') , [redirect] nvarchar(100) not null default 'n'   check([redirect] in ('n','y') or [redirect] = '') , [redirectType] nvarchar(100) null  check([redirectType] in ('page','url') or [redirectType] = '') , [redirectPageId] int not null default 0  , [redirectStatus] int not null default 302  , [redirectAlias] nvarchar(255) not null default ''  , [sorter] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_PageContent] ([idPage] int not null default 0  , [language] nvarchar(3) not null default ''  , [title] nvarchar(255) not null default ''  , [menuTitle] nvarchar(255) not null default ''  , [header] nvarchar(max) not null , [keywords] nvarchar(max) not null , [description] nvarchar(max) not null , primary key([idPage], [language]));
create table [cf_zz_PageIndex] ([id] int not null identity(1,1) , [idPage] int not null default 0  , [language] nvarchar(3) not null default ''  , [url] nvarchar(255) not null default ''   unique , [title] nvarchar(255) not null default ''  , [content] nvarchar(max) not null , [scriptDuration] float not null default 0.000000000000  , [reindex] nvarchar(100) not null default 'n'   check([reindex] in ('y','n') or [reindex] = '') , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_PageItem] ([id] int not null identity(1,1) , [idPage] int not null default 0  , [idGroup] int not null default 1  , [type] nvarchar(64) not null default ''  , [number] int null , [name] nvarchar(255) null , [title] nvarchar(255) not null default ''  , [allowDelete] nvarchar(100) not null default 'y'   check([allowDelete] in ('y','n') or [allowDelete] = '') , [sorter] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_PageItemConfig] ([id] int not null identity(1,1) , [idItem] int not null default 0  , [name] nvarchar(255) not null default ''  , [value] nvarchar(max) null , primary key([id]));
create table [cf_zz_PageOption] ([id] int not null identity(1,1) , [idPage] int not null default 0  , [name] nvarchar(50) not null default ''  , [show] nvarchar(100) not null default 'n'   check([show] in ('n','y') or [show] = '') , [value] nvarchar(100) not null default 'n'   check([value] in ('n','y') or [value] = '') , primary key([id]));
create table [cf_zz_Redirection] ([id] int not null identity(1,1) , [source] nvarchar(max) not null , [dest] nvarchar(max) not null , [status] int not null default 301  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([id]));
create table [cf_zz_Settings] ([name] nvarchar(255) not null default ''  , [idCategory] int not null default 0  , [fieldType] nvarchar(255) not null default ''  , [label] nvarchar(255) not null default ''  , [value] nvarchar(max) not null , [options] nvarchar(max) not null , [description] nvarchar(max) not null , [required] nvarchar(100) not null default 'y'   check([required] in ('y','n') or [required] = '') , [system] nvarchar(100) not null default 'n'   check([system] in ('y','n') or [system] = '') , [sorter] int not null default 0  , [added] datetime not null default '0000-00-00 00:00:00'  , [changed] datetime not null default '0000-00-00 00:00:00'  , primary key([name]));
create table [cf_zz_SettingsCategory] ([id] int not null identity(1,1) , [name] nvarchar(255) not null default ''  , [system] nvarchar(100) not null default 'n'   check([system] in ('y','n') or [system] = '') , [sorter] int not null default 0  , primary key([id]));
create table [cf_zz_SettingsOptions] ([id] int not null identity(1,1) , [name] nvarchar(255) not null default ''  , [variable] nvarchar(255) not null default ''  , [value] nvarchar(255) not null default ''  , [type] nvarchar(100) not null default 'string'   check([type] in ('string','bool','int','float','double') or [type] = '') , primary key([id]));
*/

