-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(db): fix dataconfig model import issue
- Loading branch information
Showing
7 changed files
with
64 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,2 @@ | ||
import { join } from 'path' | ||
import fs from 'fs-extra' | ||
import getAppDataPath from 'appdata-path' | ||
|
||
import ConnectionEntity from './src/database/models/ConnectionEntity' | ||
import MessageEntity from './src/database/models/MessageEntity' | ||
import SubscriptionEntity from './src/database/models/SubscriptionEntity' | ||
import ScriptEntity from './src/database/models/ScriptEntity' | ||
import SettingEntity from './src/database/models/SettingEntity' | ||
import CollectionEntity from './src/database/models/CollectionEntity' | ||
import HistoryMessageHeaderEntity from './src/database/models/HistoryMessageHeaderEntity' | ||
import HistoryMessagePayloadEntity from './src/database/models/HistoryMessagePayloadEntity' | ||
|
||
const STORE_PATH = getAppDataPath('MQTTX') | ||
|
||
try { | ||
if (!fs.pathExistsSync(STORE_PATH)) { | ||
fs.mkdirpSync(STORE_PATH) | ||
} | ||
} catch (err) { | ||
console.error(err) | ||
} | ||
|
||
const config = { | ||
type: 'sqlite', | ||
name: 'MQTTX', | ||
driver: 'sqlite', | ||
synchronize: false, | ||
logging: process.env.NODE_ENV !== 'production', | ||
entities: [ | ||
ConnectionEntity, | ||
MessageEntity, | ||
SubscriptionEntity, | ||
ScriptEntity, | ||
SettingEntity, | ||
CollectionEntity, | ||
HistoryMessageHeaderEntity, | ||
HistoryMessagePayloadEntity, | ||
], | ||
database: join(STORE_PATH, 'MQTTX.db'), | ||
migrations: [join(__dirname, './src/database/migration/**/*{.ts,.js}')], | ||
migrationsTableName: 'temp_migration_table', | ||
cli: { | ||
migrationsDir: join(__dirname, './src/database/migration'), | ||
subscribersDir: join(__dirname, './src/database/subscriber'), | ||
entitiesDir: join(__dirname, './src/database/models'), | ||
}, | ||
} | ||
export = config | ||
const ORMConfig = require('./src/database/database.config') | ||
module.exports = ORMConfig.default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,6 @@ | |
"description": "MQTT desktop client", | ||
"author": "EMQ X Team <[email protected]>", | ||
"scripts": { | ||
"db:log": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm schema:log -c MQTTX -f ormconfig.ts", | ||
"db:migration:show": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm migration:show -c MQTTX -f ormconfig.ts", | ||
"db:migration:generate": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm migration:generate -f ormconfig.ts -c MQTTX --pretty", | ||
"db:migration:run": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm migration:run -c MQTTX -f ormconfig.ts", | ||
"db:migration:revert": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm migration:revert -f ormconfig.ts -c MQTTX", | ||
"db:migration:sync": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm schema:sync -f ormconfig.ts -c MQTTX", | ||
"db:diagram": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm-uml ormconfig.ts -c MQTTX -d ./src/database/database.png", | ||
"version": "yarn run gen:version && git add -A .", | ||
"serve": "vue-cli-service serve", | ||
"build": "vue-cli-service build", | ||
|
@@ -25,7 +18,14 @@ | |
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.vue\" \"src/**/*.scss\"", | ||
"lint": "eslint --fix --ext .ts,.vue src", | ||
"test:e2e": "vue-cli-service test:e2e", | ||
"test:unit": "vue-cli-service test:unit" | ||
"test:unit": "vue-cli-service test:unit", | ||
"db:log": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm schema:log -c MQTTX -f ormconfig.ts", | ||
"db:migration:show": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm migration:show -c MQTTX -f ormconfig.ts", | ||
"db:migration:generate": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm migration:generate -f ormconfig.ts -c MQTTX --pretty", | ||
"db:migration:run": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm migration:run -c MQTTX -f ormconfig.ts", | ||
"db:migration:revert": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm migration:revert -f ormconfig.ts -c MQTTX", | ||
"db:migration:sync": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm schema:sync -f ormconfig.ts -c MQTTX", | ||
"db:diagram": "TS_NODE_PROJECT=tsconfig.commonjs.json ts-node ./node_modules/.bin/typeorm-uml ormconfig.ts -c MQTTX -d ./src/database/database.png" | ||
}, | ||
"main": "background.js", | ||
"dependencies": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { join } from 'path' | ||
import fs from 'fs-extra' | ||
import { getAppDataPath } from 'appdata-path' | ||
const STORE_PATH = getAppDataPath('MQTTX') | ||
import ConnectionEntity from './models/ConnectionEntity' | ||
import MessageEntity from './models/MessageEntity' | ||
import SubscriptionEntity from './models/SubscriptionEntity' | ||
import ScriptEntity from './models/ScriptEntity' | ||
import SettingEntity from './models/SettingEntity' | ||
import CollectionEntity from './models/CollectionEntity' | ||
import HistoryMessageHeaderEntity from './models/HistoryMessageHeaderEntity' | ||
import HistoryMessagePayloadEntity from './models/HistoryMessagePayloadEntity' | ||
import { ConnectionOptions } from 'typeorm' | ||
|
||
try { | ||
if (!fs.pathExistsSync(STORE_PATH)) { | ||
fs.mkdirpSync(STORE_PATH) | ||
} | ||
} catch (err) { | ||
console.error(err) | ||
} | ||
|
||
const ORMConfig = { | ||
type: 'sqlite', | ||
name: 'MQTTX', | ||
driver: 'sqlite', | ||
synchronize: false, | ||
logging: process.env.NODE_ENV !== 'production', | ||
database: join(STORE_PATH, 'MQTTX.db'), | ||
migrations: ['database/migration/*{.ts,.js}'], | ||
migrationsTableName: 'temp_migration_table', | ||
migrationsRun: true, | ||
entities: [ | ||
ConnectionEntity, | ||
MessageEntity, | ||
SubscriptionEntity, | ||
ScriptEntity, | ||
SettingEntity, | ||
CollectionEntity, | ||
HistoryMessageHeaderEntity, | ||
HistoryMessagePayloadEntity, | ||
], | ||
cli: { | ||
migrationsDir: 'src/database/migration', | ||
subscribersDir: 'src/database/subscriber', | ||
entitiesDir: 'src/database/models', | ||
}, | ||
} as ConnectionOptions | ||
export default ORMConfig |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters