diff --git a/app/service/mysql.js b/app/service/mysql.js index 494f6a6..4b30ba1 100644 --- a/app/service/mysql.js +++ b/app/service/mysql.js @@ -4,32 +4,34 @@ const Service = require('egg').Service; class MysqlService extends Service { consoleQuery(sql, params) { - const { ctx: { app: { mysql } } } = this; - const xprofiler_console = mysql.get('xprofiler_console'); - return xprofiler_console.query(sql, params); + return this.app.model.query(sql, { replacements: params, type: this.app.model.QueryTypes.SELECT }); + // const { ctx: { app: { mysql } } } = this; + // const xprofiler_console = mysql.get('xprofiler_console'); + // return xprofiler_console.query(sql, params); } logsQuery(sql, params) { - const { ctx: { app: { mysql } } } = this; - const xprofiler_logs = mysql.get('xprofiler_logs'); - return xprofiler_logs.query(sql, params); + return this.app.model.query(sql, { replacements: params, type: this.app.model.QueryTypes.SELECT }); + // const { ctx: { app: { mysql } } } = this; + // const xprofiler_logs = mysql.get('xprofiler_logs'); + // return xprofiler_logs.query(sql, params); } /* table */ getUserByName(name) { - const sql = 'SELECT * FROM user WHERE name = ?'; + const sql = 'SELECT * FROM xprofiler_console.user WHERE name = ?'; const params = [name]; return this.consoleQuery(sql, params).then(data => data[0]); } saveUser(name, nick, pass, identity, mail) { - const sql = 'INSERT INTO user (name, nick, pass, identity, mail) VALUES (?, ?, ?, ?, ?)'; + const sql = 'INSERT INTO xprofiler_console.user (name, nick, pass, identity, mail) VALUES (?, ?, ?, ?, ?)'; const params = [name, nick, pass, identity, mail]; return this.consoleQuery(sql, params); } getUserByIdentity(identity) { - const sql = 'SELECT * FROM user WHERE identity = ?'; + const sql = 'SELECT * FROM xprofiler_console.user WHERE identity = ?'; const params = [identity]; return this.consoleQuery(sql, params).then(data => data[0]); } @@ -38,62 +40,62 @@ class MysqlService extends Service { if (!userIds.length) { return []; } - const sql = `SELECT * FROM user WHERE id in (${userIds.map(() => '?').join(',')})`; + const sql = `SELECT * FROM xprofiler_console.user WHERE id in (${userIds.map(() => '?').join(',')})`; const params = [...userIds]; return this.consoleQuery(sql, params); } /* table */ getMyApps(userId) { - const sql = 'SELECT * FROM apps WHERE owner = ? ORDER BY gm_modified ASC'; + const sql = 'SELECT * FROM xprofiler_console.apps WHERE owner = ? ORDER BY gm_modified ASC'; const params = [userId]; return this.consoleQuery(sql, params); } getJoinedApps(userId, status) { - const sql = 'SELECT * FROM apps WHERE id in (SELECT app FROM members WHERE user = ? AND status = ?) ORDER BY gm_modified ASC'; + const sql = 'SELECT * FROM xprofiler_console.apps WHERE id in (SELECT app FROM xprofiler_console.members WHERE user = ? AND status = ?) ORDER BY gm_modified ASC'; const params = [userId, status]; return this.consoleQuery(sql, params); } saveApp(userId, appName, secret) { - const sql = 'INSERT INTO apps (name, owner, secret) VALUES (?, ?, ?)'; + const sql = 'INSERT INTO xprofiler_console.apps (name, owner, secret) VALUES (?, ?, ?)'; const params = [appName, userId, secret]; return this.consoleQuery(sql, params); } renameApp(appId, newAppName) { - const sql = 'UPDATE apps SET name = ? WHERE id = ?'; + const sql = 'UPDATE xprofiler_console.apps SET name = ? WHERE id = ?'; const params = [newAppName, appId]; return this.consoleQuery(sql, params); } getAppByAppId(appId) { - const sql = 'SELECT * FROM apps WHERE id = ?'; + const sql = 'SELECT * FROM xprofiler_console.apps WHERE id = ?'; const params = [appId]; return this.consoleQuery(sql, params).then(data => data[0] || {}); } deleteAppByAppId(appId) { - const sql = 'DELETE FROM apps WHERE id = ?'; + const sql = 'DELETE FROM xprofiler_console.apps WHERE id = ?'; const params = [appId]; return this.consoleQuery(sql, params); } checkAppOwnerByUserId(appId, userId) { - const sql = 'SELECT * FROM apps WHERE id = ? AND owner = ?'; + const sql = 'SELECT * FROM xprofiler_console.apps WHERE id = ? AND owner = ?'; const params = [appId, userId]; return this.consoleQuery(sql, params).then(data => data[0]); } checkAppMemberByUserId(appId, userId, status) { - const sql = 'SELECT * FROM apps WHERE id in (SELECT app FROM members WHERE app = ? AND user = ? AND status = ?)'; + const sql = 'SELECT * FROM xprofiler_console.apps WHERE id in (SELECT app FROM xprofiler_console.members WHERE app = ? AND user = ? AND status = ?)'; const params = [appId, userId, status]; return this.consoleQuery(sql, params).then(data => data[0]); } updateAppOwner(appId, userId) { - const sql = 'UPDATE apps SET owner = ? WHERE id = ?'; + const sql = 'UPDATE xprofiler_console.apps SET owner = ? WHERE id = ?'; const params = [userId, appId]; return this.consoleQuery(sql, params); } @@ -103,13 +105,13 @@ class MysqlService extends Service { let sql = ''; let params = []; if (type === 'all') { - sql = 'SELECT * FROM files WHERE app = ?'; + sql = 'SELECT * FROM xprofiler_console.files WHERE app = ?'; params = [appId]; } else if (type === 'favor') { - sql = 'SELECT * FROM files WHERE app = ? AND favor = ?'; + sql = 'SELECT * FROM xprofiler_console.files WHERE app = ? AND favor = ?'; params = [appId, 1]; } else { - sql = 'SELECT * FROM files WHERE app = ? AND type = ?'; + sql = 'SELECT * FROM xprofiler_console.files WHERE app = ? AND type = ?'; params = [appId, type]; } sql += ' ORDER BY gm_create DESC'; @@ -117,14 +119,14 @@ class MysqlService extends Service { } addFile(appId, agentId, type, file, user, status = 0, storage = '') { - const sql = 'INSERT INTO files (app, agent, type, file, user, status, storage) ' + const sql = 'INSERT INTO xprofiler_console.files (app, agent, type, file, user, status, storage) ' + 'VALUES (?, ?, ?, ?, ?, ?, ?)'; const params = [appId, agentId, type, file, user, status, storage]; return this.consoleQuery(sql, params); } getFileByIdAndType(fileId, fileType) { - const sql = 'SELECT * FROM files WHERE id = ? AND type = ?'; + const sql = 'SELECT * FROM xprofiler_console.files WHERE id = ? AND type = ?'; const params = [fileId, fileType]; return this.consoleQuery(sql, params).then(data => data[0]); } @@ -133,29 +135,29 @@ class MysqlService extends Service { let sql = ''; let params = []; if (storage) { - sql = 'UPDATE files SET status = ?, token = ?, storage = ? WHERE id = ?'; + sql = 'UPDATE xprofiler_console.files SET status = ?, token = ?, storage = ? WHERE id = ?'; params = [status, token, storage, fileId]; } else { - sql = 'UPDATE files SET status = ?, token = ? WHERE id = ?'; + sql = 'UPDATE xprofiler_console.files SET status = ?, token = ? WHERE id = ?'; params = [status, token, fileId]; } return this.consoleQuery(sql, params); } deleteFileById(fileId) { - const sql = 'DELETE FROM files WHERE id = ?'; + const sql = 'DELETE FROM xprofiler_console.files WHERE id = ?'; const params = [fileId]; return this.consoleQuery(sql, params); } deleteFiles(appId) { - const sql = 'DELETE FROM files WHERE app = ?'; + const sql = 'DELETE FROM xprofiler_console.files WHERE app = ?'; const params = [appId]; return this.consoleQuery(sql, params); } updateFileFavor(fileId, favor) { - const sql = 'UPDATE files SET favor = ? WHERE id = ?'; + const sql = 'UPDATE xprofiler_console.files SET favor = ? WHERE id = ?'; const params = [favor, fileId]; return this.consoleQuery(sql, params); } @@ -165,80 +167,80 @@ class MysqlService extends Service { let sql; let params = []; if (type === 'favor') { - sql = 'SELECT * FROM coredumps WHERE app = ? AND favor = ?'; + sql = 'SELECT * FROM xprofiler_console.coredumps WHERE app = ? AND favor = ?'; params = [appId, 1]; } else { - sql = 'SELECT * FROM coredumps WHERE app = ?'; + sql = 'SELECT * FROM xprofiler_console.coredumps WHERE app = ?'; params = [appId]; } return this.consoleQuery(sql, params); } addCoredump(appId, agentId, file, node, user, fileStatus = 0, fileStorage = '', nodeStatus, nodeStorage = '') { - const sql = 'INSERT INTO coredumps (app, agent, file, node, user, file_status, file_storage, node_status, node_storage) ' + const sql = 'INSERT INTO xprofiler_console.coredumps (app, agent, file, node, user, file_status, file_storage, node_status, node_storage) ' + 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'; const params = [appId, agentId, file, node, user, fileStatus, fileStorage, nodeStatus, nodeStorage]; return this.consoleQuery(sql, params); } getCoredumpById(fileId) { - const sql = 'SELECT * FROM coredumps WHERE id = ?'; + const sql = 'SELECT * FROM xprofiler_console.coredumps WHERE id = ?'; const params = [fileId]; return this.consoleQuery(sql, params).then(data => data[0]); } deleteCoredumpById(fileId) { - const sql = 'DELETE FROM coredumps WHERE id = ?'; + const sql = 'DELETE FROM xprofiler_console.coredumps WHERE id = ?'; const params = [fileId]; return this.consoleQuery(sql, params); } deleteCoredumps(appId) { - const sql = 'DELETE FROM coredumps WHERE app = ?'; + const sql = 'DELETE FROM xprofiler_console.coredumps WHERE app = ?'; const params = [appId]; return this.consoleQuery(sql, params); } updateCoredumpFavor(fileId, favor) { - const sql = 'UPDATE coredumps SET favor = ? WHERE id = ?'; + const sql = 'UPDATE xprofiler_console.coredumps SET favor = ? WHERE id = ?'; const params = [favor, fileId]; return this.consoleQuery(sql, params); } /* table */ getTeamMembersByAppId(appId) { - const sql = 'SELECT * FROM members WHERE app = ?'; + const sql = 'SELECT * FROM xprofiler_console.members WHERE app = ?'; const params = [appId]; return this.consoleQuery(sql, params); } inviteMember(appId, invitedUser, status) { - const sql = 'INSERT INTO members (app, user, status) VALUES (?, ?, ?)'; + const sql = 'INSERT INTO xprofiler_console.members (app, user, status) VALUES (?, ?, ?)'; const params = [appId, invitedUser, status]; return this.consoleQuery(sql, params); } confirmInvitation(invitedApp, userId) { - const sql = 'UPDATE members SET status = ? WHERE app = ? AND user = ?'; + const sql = 'UPDATE xprofiler_console.members SET status = ? WHERE app = ? AND user = ?'; const params = [2, invitedApp, userId]; return this.consoleQuery(sql, params); } deleteMember(appId, userId) { - const sql = 'DELETE FROM members WHERE app = ? AND user = ?'; + const sql = 'DELETE FROM xprofiler_console.members WHERE app = ? AND user = ?'; const params = [appId, userId]; return this.consoleQuery(sql, params); } deleteMembersByAppId(appId) { - const sql = 'DELETE FROM members WHERE app = ?'; + const sql = 'DELETE FROM xprofiler_console.members WHERE app = ?'; const params = [appId]; return this.consoleQuery(sql, params); } /* table */ getStrategiesByAppId(appId) { - const sql = 'SELECT * FROM strategies WHERE app = ? ORDER BY gm_create DESC'; + const sql = 'SELECT * FROM xprofiler_console.strategies WHERE app = ? ORDER BY gm_create DESC'; const params = [appId]; return this.consoleQuery(sql, params); } @@ -246,7 +248,7 @@ class MysqlService extends Service { addStrategy(data) { const { appId, contextType, pushType, customRuleExpr, customRuleDesc, webhookPush, webhookType = '', webhookAddress = '', webhookSign = '' } = data; - const sql = 'INSERT INTO strategies (app, context, push, webhook, wtype, waddress, wsign, ' + const sql = 'INSERT INTO xprofiler_console.strategies (app, context, push, webhook, wtype, waddress, wsign, ' + 'expression, content) ' + 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'; const params = [appId, contextType, pushType, @@ -259,7 +261,7 @@ class MysqlService extends Service { } getStrategyById(strategyId) { - const sql = 'SELECT * FROM strategies WHERE id = ?'; + const sql = 'SELECT * FROM xprofiler_console.strategies WHERE id = ?'; const params = [strategyId]; return this.consoleQuery(sql, params).then(data => data[0]); } @@ -267,7 +269,7 @@ class MysqlService extends Service { updateStrategy(data) { const { strategyId, contextType, pushType, customRuleExpr, customRuleDesc, webhookPush, webhookType = '', webhookAddress = '', webhookSign = '' } = data; - const sql = 'UPDATE strategies SET context = ?, push = ?, expression = ?, content = ?, ' + const sql = 'UPDATE xprofiler_console.strategies SET context = ?, push = ?, expression = ?, content = ?, ' + 'webhook = ?, wtype = ?, waddress = ?, wsign = ? WHERE id = ?'; const params = [contextType, pushType, customRuleExpr, customRuleDesc, webhookPush ? 1 : 0, @@ -279,39 +281,39 @@ class MysqlService extends Service { } updateStrategyStatus(strategyId, status) { - const sql = 'UPDATE strategies SET status = ? WHERE id = ?'; + const sql = 'UPDATE xprofiler_console.strategies SET status = ? WHERE id = ?'; const params = [status, strategyId]; return this.consoleQuery(sql, params); } deleteStrategyById(strategyId) { - const sql = 'DELETE FROM strategies WHERE id = ?'; + const sql = 'DELETE FROM xprofiler_console.strategies WHERE id = ?'; const params = [strategyId]; return this.consoleQuery(sql, params); } /* table */ getContactsByStrategyId(strategyId) { - const sql = 'SELECT * FROM contacts WHERE strategy = ?'; + const sql = 'SELECT * FROM xprofiler_console.contacts WHERE strategy = ?'; const params = [strategyId]; return this.consoleQuery(sql, params); } addContactToStrategy(strategyId, userId) { - const sql = 'INSERT INTO contacts (strategy, user) VALUES (?, ?)'; + const sql = 'INSERT INTO xprofiler_console.contacts (strategy, user) VALUES (?, ?)'; const params = [strategyId, userId]; return this.consoleQuery(sql, params); } deleteContactFromStrategy(strategyId, userId) { - const sql = 'DELETE FROM contacts WHERE strategy = ? AND user = ?'; + const sql = 'DELETE FROM xprofiler_console.contacts WHERE strategy = ? AND user = ?'; const params = [strategyId, userId]; return this.consoleQuery(sql, params); } /* process_${DD} or osinfo_${DD} */ getXnppLogs(table, appId, agentId, start, end, pid) { - const sql = `SELECT * FROM ${table} WHERE app = ? AND agent = ? ` + const sql = `SELECT * FROM xprofiler_logs.${table} WHERE app = ? AND agent = ? ` + 'AND log_time >= ? AND log_time < ? ' + (pid ? 'AND pid = ?' : '') + 'ORDER BY log_time DESC'; @@ -324,7 +326,7 @@ class MysqlService extends Service { /* alarm_${DD} */ getAlarmHistory(table, strategyId, start, end) { - const sql = `SELECT * FROM ${table} WHERE strategy = ? ` + const sql = `SELECT * FROM xprofiler_logs.${table} WHERE strategy = ? ` + 'AND gm_create >= ? AND gm_create < ? ' + 'ORDER BY gm_create DESC'; const params = [strategyId, start, end]; diff --git a/config/config.default.js b/config/config.default.js index 8c3cc50..133a527 100644 --- a/config/config.default.js +++ b/config/config.default.js @@ -1,9 +1,9 @@ /* eslint valid-jsdoc: "off" */ -'use strict'; +'use strict' -const fs = require('fs'); -const path = require('path'); +const fs = require('fs') +const path = require('path') /** * @param {Egg.EggAppInfo} appInfo app info @@ -13,35 +13,33 @@ module.exports = appInfo => { * built-in config * @type {Egg.EggAppConfig} **/ - const config = exports = {}; + const config = (exports = {}) - config.keys = appInfo.name + '_1588763657594_4897'; + config.keys = appInfo.name + '_1588763657594_4897' config.development = { - watchDirs: ['lib'], - }; + watchDirs: ['lib'] + } config.static = { - gzip: true, - }; + gzip: true + } config.siteFile = { - '/favicon.ico': fs.readFileSync(path.join(__dirname, '../app/public/favicon.ico')), - }; + '/favicon.ico': fs.readFileSync(path.join(__dirname, '../app/public/favicon.ico')) + } config.view = { mapping: { - '.html': 'nunjucks', - }, - }; + '.html': 'nunjucks' + } + } config.security = { csrf: { - ignore: [ - '/xapi/upload_from_xtransit', - ], - }, - }; + ignore: ['/xapi/upload_from_xtransit'] + } + } config.multipart = { fileSize: '4096mb', @@ -53,58 +51,66 @@ module.exports = appInfo => { '.diag', '.core', '.node', - '.trend', + '.trend' ], - mode: 'file', - }; + mode: 'file' + } config.secure = { - secret: 'easy-monitor::xprofiler', - }; + secret: 'easy-monitor::xprofiler' + } - config.httpTimeout = 15000; + config.httpTimeout = 15000 config.profilingTime = { start_cpu_profiling: 5 * 60 * 1000, start_heap_profiling: 5 * 60 * 1000, - start_gc_profiling: 5 * 60 * 1000, - }; + start_gc_profiling: 5 * 60 * 1000 + } - config.profilingTimeExtra = 15 * 1000; + config.profilingTimeExtra = 15 * 1000 - config.profilingTimeExpired = 60 * 1000; + config.profilingTimeExpired = 60 * 1000 config.actionTime = { cpuprofile: { profilingTime: config.profilingTime.start_cpu_profiling + config.profilingTimeExtra, - expired: config.profilingTime.start_cpu_profiling + config.profilingTimeExpired, + expired: config.profilingTime.start_cpu_profiling + config.profilingTimeExpired }, heapprofile: { profilingTime: config.profilingTime.start_heap_profiling + config.profilingTimeExtra, - expired: config.profilingTime.start_heap_profiling + config.profilingTimeExpired, + expired: config.profilingTime.start_heap_profiling + config.profilingTimeExpired }, gcprofile: { profilingTime: config.profilingTime.start_gc_profiling + config.profilingTimeExtra, - expired: config.profilingTime.start_gc_profiling + config.profilingTimeExpired, + expired: config.profilingTime.start_gc_profiling + config.profilingTimeExpired }, heapsnapshot: { profilingTime: config.profilingTimeExtra, - expired: config.profilingTimeExpired, + expired: config.profilingTimeExpired }, diag: { profilingTime: config.profilingTimeExtra, - expired: config.profilingTimeExpired, - }, - }; - - config.uploadFileExpiredTime = 20 * 60 * 1000; - - config.auditExpiredTime = 15 * 1000; - - config.uploadNoncePrefix = 'XTRANSIT_UPLOAD_NONCE::'; - - const userConfig = {}; - + expired: config.profilingTimeExpired + } + } + + config.uploadFileExpiredTime = 20 * 60 * 1000 + + config.auditExpiredTime = 15 * 1000 + + config.uploadNoncePrefix = 'XTRANSIT_UPLOAD_NONCE::' + + const userConfig = {} + // sequelize + userConfig.sequelize = { + dialect: 'postgres', + database: '', + host: '', + port: 7092, + username: '', + password: '' + } // mysql userConfig.mysql = { app: true, @@ -115,37 +121,37 @@ module.exports = appInfo => { port: 3306, user: '', password: '', - database: 'xprofiler_console', + database: 'xprofiler_console' }, xprofiler_logs: { host: '', port: 3306, user: '', password: '', - database: 'xprofiler_logs', - }, - }, - }; + database: 'xprofiler_logs' + } + } + } // redis userConfig.redis = { client: { sentinels: null, port: 6379, - host: '', - password: '', - db: 0, - }, - }; + host: '127.0.0.1', + password: '123456', + db: 0 + } + } // xtransit upload file - userConfig.xprofilerConsole = ''; + userConfig.xprofilerConsole = 'http://127.0.0.1:8443' // xtransit manager - userConfig.xtransitManager = ''; + userConfig.xtransitManager = 'http://127.0.0.1:8543' return { ...config, - ...userConfig, - }; -}; + ...userConfig + } +} diff --git a/config/plugin.js b/config/plugin.js index d7e3deb..d6bf310 100644 --- a/config/plugin.js +++ b/config/plugin.js @@ -10,6 +10,11 @@ module.exports = { package: 'egg-view-nunjucks', }, + sequelize: { + enable: true, + package: 'egg-sequelize', + }, + mysql: { enable: true, package: 'egg-mysql', diff --git a/db/pgsqlinit.sql b/db/pgsqlinit.sql new file mode 100644 index 0000000..be583bb --- /dev/null +++ b/db/pgsqlinit.sql @@ -0,0 +1,131 @@ +-- File name: C:\Users\songxiaodong5\Desktop\pl\abc.sql +-- Created by DBConvert http://www.dbconvert.com + + +-- +-- Table structure for table `apps` +-- + +CREATE TABLE "apps" ( "id" BIGSERIAL NOT NULL , + "name" VARCHAR(50) NOT NULL , + "owner" BIGINT NOT NULL , + "secret" VARCHAR(50) NOT NULL , + "gm_modified" TIMESTAMP NULL , + "gm_create" TIMESTAMP NULL , + PRIMARY KEY ("id"), + UNIQUE ("owner","name") +); +CREATE INDEX "apps_owner_2" ON "apps" ("owner"); + + +-- +-- Table structure for table `contacts` +-- + +CREATE TABLE "contacts" ( "id" BIGSERIAL NOT NULL , + "strategy" BIGINT NOT NULL , + "user" BIGINT NOT NULL , + "gm_modified" TIMESTAMP NULL , + "gm_create" TIMESTAMP NULL , + PRIMARY KEY ("id"), + UNIQUE ("strategy","user") +); +CREATE INDEX "contacts_strategy_2" ON "contacts" ("strategy"); + + +-- +-- Table structure for table `coredumps` +-- + +CREATE TABLE "coredumps" ( "id" BIGSERIAL NOT NULL , + "app" INTEGER NOT NULL , + "agent" VARCHAR(50) NOT NULL , + "file" VARCHAR(250) NOT NULL , + "file_storage" VARCHAR(250) NULL , + "file_status" SMALLINT NULL DEFAULT 0, + "node" VARCHAR(250) NOT NULL , + "node_storage" VARCHAR(250) NULL , + "node_status" SMALLINT NULL DEFAULT 0, + "user" BIGINT NOT NULL , + "favor" SMALLINT NULL DEFAULT 0, + "token" VARCHAR(50) NULL , + "gm_modified" TIMESTAMP NULL , + "gm_create" TIMESTAMP NULL , + PRIMARY KEY ("id"), + UNIQUE ("app","agent","file","file_storage") +); +CREATE INDEX "coredumps_id" ON "coredumps" ("id","app"); + + +-- +-- Table structure for table `files` +-- + +CREATE TABLE "files" ( "id" BIGSERIAL NOT NULL , + "app" INTEGER NOT NULL , + "agent" VARCHAR(50) NOT NULL , + "type" VARCHAR(50) NOT NULL , + "file" VARCHAR(250) NOT NULL , + "storage" VARCHAR(250) NULL , + "user" BIGINT NOT NULL , + "status" SMALLINT NULL DEFAULT 0, + "favor" SMALLINT NULL DEFAULT 0, + "token" VARCHAR(50) NULL , + "gm_modified" TIMESTAMP NULL , + "gm_create" TIMESTAMP NULL , + PRIMARY KEY ("id"), + UNIQUE ("app","agent","file","storage") +); +CREATE INDEX "files_id" ON "files" ("id","app","type"); + + +-- +-- Table structure for table `strategies` +-- + +CREATE TABLE "strategies" ( "id" BIGSERIAL NOT NULL , + "app" INTEGER NOT NULL , + "context" VARCHAR(50) NOT NULL , + "push" VARCHAR(50) NOT NULL , + "webhook" SMALLINT NULL DEFAULT 0, + "wtype" VARCHAR(20) NULL , + "waddress" VARCHAR(200) NULL , + "wsign" VARCHAR(100) NULL , + "expression" VARCHAR(150) NOT NULL , + "content" VARCHAR(150) NOT NULL , + "status" SMALLINT NULL DEFAULT 1., + "gm_modified" TIMESTAMP NULL , + "gm_create" TIMESTAMP NULL , + PRIMARY KEY ("id") +); +CREATE INDEX "strategies_id" ON "strategies" ("id","app"); + + +-- +-- Table structure for table `user` +-- + +CREATE TABLE "user" ( "id" BIGSERIAL NOT NULL , + "name" VARCHAR(100) NOT NULL , + "nick" VARCHAR(100) NOT NULL , + "pass" VARCHAR(200) NOT NULL , + "identity" VARCHAR(20) NOT NULL , + "mail" VARCHAR(250) NOT NULL , + "gm_modified" TIMESTAMP NULL , + "gm_create" TIMESTAMP NULL , + PRIMARY KEY ("id"), + UNIQUE ("name"), + UNIQUE ("identity") +); + + +-- +-- Table structure for table `users` +-- + +CREATE TABLE "users" ( "id" BIGSERIAL NOT NULL , + "name" VARCHAR(100) NULL , + "created_at" VARCHAR(100) NULL , + "updated_at" VARCHAR(100) NULL , + PRIMARY KEY ("id") +); \ No newline at end of file