Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Use new mikro-orm checkMigrationNeeded method to prevent unnecessary …
Browse files Browse the repository at this point in the history
…migration attempts (#59)
  • Loading branch information
GoldingAustin authored Jan 12, 2023
1 parent bf1e3d2 commit 3ea36b2
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 85 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"@carbon/icons-react": "^10.36.0",
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"@mikro-orm/better-sqlite": "5.5.3",
"@mikro-orm/core": "5.5.3",
"@mikro-orm/better-sqlite": "5.6.6",
"@mikro-orm/core": "5.6.6",
"@openfonts/ibm-plex-mono_all": "^1.44.2",
"@openfonts/ibm-plex-sans_all": "^1.44.2",
"@tanstack/react-query": "^4.1.3",
Expand Down Expand Up @@ -99,9 +99,9 @@
"devDependencies": {
"@changesets/cli": "^2.22.0",
"@emotion/babel-plugin": "^11.10.0",
"@mikro-orm/entity-generator": "5.5.3",
"@mikro-orm/migrations": "5.5.3",
"@mikro-orm/seeder": "5.5.3",
"@mikro-orm/entity-generator": "5.6.6",
"@mikro-orm/migrations": "5.6.6",
"@mikro-orm/seeder": "5.6.6",
"@nrwl/cli": "^14.6.3",
"@nrwl/cypress": "^14.6.3",
"@nrwl/devkit": "^14.6.3",
Expand Down
12 changes: 7 additions & 5 deletions packages/migrations/src/get-migrated-orm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ export const getMigratedMainORM = async (production: boolean, dbPath: string) =>
};

const migrate = async (orm: ORM) => {
try {
const migrator = orm.getMigrator();
await migrator.up();
} catch (e) {
console.error(`Error migrating database ${orm.config.get('dbName')}`, e);
const migrator = orm.getMigrator();
if (await migrator.checkMigrationNeeded()) {
try {
await migrator.up();
} catch (e) {
console.error(`Error migrating database ${orm.config.get('dbName')}`, e);
}
}
return orm;
};
147 changes: 72 additions & 75 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2849,13 +2849,13 @@ __metadata:
languageName: node
linkType: hard

"@mikro-orm/better-sqlite@npm:5.5.3":
version: 5.5.3
resolution: "@mikro-orm/better-sqlite@npm:5.5.3"
"@mikro-orm/better-sqlite@npm:5.6.6":
version: 5.6.6
resolution: "@mikro-orm/better-sqlite@npm:5.6.6"
dependencies:
"@mikro-orm/knex": ^5.5.3
better-sqlite3: 7.6.2
fs-extra: 10.1.0
"@mikro-orm/knex": ~5.6.6
better-sqlite3: 8.0.1
fs-extra: 11.1.0
sqlstring-sqlite: 0.1.1
peerDependencies:
"@mikro-orm/core": ^5.0.0
Expand All @@ -2869,20 +2869,20 @@ __metadata:
optional: true
"@mikro-orm/seeder":
optional: true
checksum: 1b30d24c51738b5cce75febba77a6a31cb6145264596e5a048bbcbe8d3dedcebd3702ed9d78c498b4296453536151ee956130d5efcae2b90b1c0d581b3de5776
checksum: 345a35679a1e0eff5f84a4959ab5557f5dd126dec41831965a44745c1e31e4106d5962e566ecbba0cf58dac9e1ed2feb9684bc8ccc230531f516ab440ab3cb83
languageName: node
linkType: hard

"@mikro-orm/core@npm:5.5.3":
version: 5.5.3
resolution: "@mikro-orm/core@npm:5.5.3"
"@mikro-orm/core@npm:5.6.6":
version: 5.6.6
resolution: "@mikro-orm/core@npm:5.6.6"
dependencies:
acorn-loose: 8.3.0
acorn-walk: 8.2.0
dotenv: 16.0.3
fs-extra: 10.1.0
globby: 11.0.4
mikro-orm: ^5.5.3
fs-extra: 11.1.0
globby: 11.1.0
mikro-orm: ~5.6.6
reflect-metadata: 0.1.13
peerDependencies:
"@mikro-orm/better-sqlite": ^5.0.0
Expand Down Expand Up @@ -2916,34 +2916,34 @@ __metadata:
optional: true
"@mikro-orm/sqlite":
optional: true
checksum: 54b1f709c687fdf2152a4f7ab41b2c9bf88a7493edc69c2f47d1f0a6f6d7eb5c1fb055da5e393020f31f68acce7b5854197514bf4094220c87581e3e276564a2
checksum: 60e99cfaadd2ff23788a98a96c901dd96f43e2422286393f5a66010b942b20a7457ae09cf01749bc6ca90ac48a52d4fcf7f0a1dd45c344d5fd12699cec1c5a18
languageName: node
linkType: hard

"@mikro-orm/entity-generator@npm:5.5.3":
version: 5.5.3
resolution: "@mikro-orm/entity-generator@npm:5.5.3"
"@mikro-orm/entity-generator@npm:5.6.6":
version: 5.6.6
resolution: "@mikro-orm/entity-generator@npm:5.6.6"
dependencies:
"@mikro-orm/knex": ^5.5.3
fs-extra: 10.1.0
"@mikro-orm/knex": ~5.6.6
fs-extra: 11.1.0
peerDependencies:
"@mikro-orm/core": ^5.0.0
checksum: f885c068838a017631f8113e98393040246c9473c93629f92c10b1b240f201defb36899a2a55799ad0cc7abdc1517e01344b0a669d3f352b451dd9f76aafd38c
checksum: b82a1ce86df0eb98ea9ff2d14bf8e2dd3cfd4b038b1926a1b6fc0b39ec38913d5d76ad2d6a350c18e9fd17f718ebf801880a4cbc4168b7d7036a4be9bd6f3181
languageName: node
linkType: hard

"@mikro-orm/knex@npm:^5.5.3":
version: 5.5.3
resolution: "@mikro-orm/knex@npm:5.5.3"
"@mikro-orm/knex@npm:~5.6.6":
version: 5.6.6
resolution: "@mikro-orm/knex@npm:5.6.6"
dependencies:
fs-extra: 10.1.0
knex: 2.3.0
fs-extra: 11.1.0
knex: 2.4.0
sqlstring: 2.3.3
peerDependencies:
"@mikro-orm/core": ^5.0.0
"@mikro-orm/entity-generator": ^5.0.0
"@mikro-orm/migrations": ^5.0.0
better-sqlite3: ^7.0.0
better-sqlite3: ^8.0.0
mssql: ^7.0.0
mysql: ^2.18.1
mysql2: ^2.1.0
Expand All @@ -2966,34 +2966,34 @@ __metadata:
optional: true
sqlite3:
optional: true
checksum: 787d5e4a6bb55763b6451ce9220912549fe6db6aa9504cf5574586c46d8c6367c42d5e05bb3551e68325af5ad840c31e2a34358c397bab9ea2a08c42afa65ae5
checksum: 31d2681bf9864bf3e9d13f40a86deb382317522fdf2ceba7d2e72a03af0331ff7036a6c608bf347d29ac6c4e1b322d4f589f987c808804cc3605c1f383f3bf82
languageName: node
linkType: hard

"@mikro-orm/migrations@npm:5.5.3":
version: 5.5.3
resolution: "@mikro-orm/migrations@npm:5.5.3"
"@mikro-orm/migrations@npm:5.6.6":
version: 5.6.6
resolution: "@mikro-orm/migrations@npm:5.6.6"
dependencies:
"@mikro-orm/knex": ^5.5.3
fs-extra: 10.1.0
knex: 2.3.0
"@mikro-orm/knex": ~5.6.6
fs-extra: 11.1.0
knex: 2.4.0
umzug: 3.2.1
peerDependencies:
"@mikro-orm/core": ^5.0.0
checksum: 992dc9c96d9bd3947044f551cc4774f4828fcbef0a848d48c639030acf9b650bfab24060b755c80bfc6917404101e6694e02cc796b56fec46cf3660be4de1242
checksum: fe8fea32199bdee97ebfc02c00564674161dfb784fb45bcba4f67f2b4e37576be10fd51d7410f6b9ebaed22e72cde0804de3858673a9b9ad60d14fc8a6429d53
languageName: node
linkType: hard

"@mikro-orm/seeder@npm:5.5.3":
version: 5.5.3
resolution: "@mikro-orm/seeder@npm:5.5.3"
"@mikro-orm/seeder@npm:5.6.6":
version: 5.6.6
resolution: "@mikro-orm/seeder@npm:5.6.6"
dependencies:
"@faker-js/faker": 7.6.0
fs-extra: 10.1.0
globby: 11.0.4
fs-extra: 11.1.0
globby: 11.1.0
peerDependencies:
"@mikro-orm/core": ^5.0.0
checksum: 148d23260ff4e2f159d77653d9ca533b0bdde5515cffd06330a414035ee1d70dd70b62c20ea9d2800bfa3140378730f4df913aa69941747ab5f1d3cc07c46b11
checksum: 003d96abfab9e2d0e82e1e867cb477fb1a515333d2de61d4be5b5b841fcdbe1c9848daca6efc49ef591d2ac22e2ae0518feb777083ed99b9e4143713861c2533
languageName: node
linkType: hard

Expand Down Expand Up @@ -6784,14 +6784,14 @@ __metadata:
languageName: node
linkType: hard

"better-sqlite3@npm:7.6.2":
version: 7.6.2
resolution: "better-sqlite3@npm:7.6.2"
"better-sqlite3@npm:8.0.1":
version: 8.0.1
resolution: "better-sqlite3@npm:8.0.1"
dependencies:
bindings: ^1.5.0
node-gyp: latest
prebuild-install: ^7.1.0
checksum: 45159e535d2c4f81456f85adcfef82e8a49025ca3e70a79bb8c0a47c13e4d822633a51b457cc37b986c42f8912344152091c91cab485048a187900aab7e7d619
checksum: 533b2cc32bd54e2a943a4f63e079f8cc8945879b7a0ebd2085b948824ea067792f6f903ab75ba75d7cafc5f8f973354cdf9a042fa6216e077925d07a8df1bead
languageName: node
linkType: hard

Expand Down Expand Up @@ -10492,7 +10492,7 @@ __metadata:
languageName: node
linkType: hard

"fast-glob@npm:3.2.11, fast-glob@npm:^3.0.3, fast-glob@npm:^3.1.1, fast-glob@npm:^3.2.11, fast-glob@npm:^3.2.4, fast-glob@npm:^3.2.5, fast-glob@npm:^3.2.7, fast-glob@npm:^3.2.9":
"fast-glob@npm:3.2.11, fast-glob@npm:^3.0.3, fast-glob@npm:^3.2.11, fast-glob@npm:^3.2.4, fast-glob@npm:^3.2.5, fast-glob@npm:^3.2.7, fast-glob@npm:^3.2.9":
version: 3.2.11
resolution: "fast-glob@npm:3.2.11"
dependencies:
Expand Down Expand Up @@ -10846,7 +10846,18 @@ __metadata:
languageName: node
linkType: hard

"fs-extra@npm:10.1.0, fs-extra@npm:^10.0.0, fs-extra@npm:^10.1.0":
"fs-extra@npm:11.1.0":
version: 11.1.0
resolution: "fs-extra@npm:11.1.0"
dependencies:
graceful-fs: ^4.2.0
jsonfile: ^6.0.1
universalify: ^2.0.0
checksum: 5ca476103fa1f5ff4a9b3c4f331548f8a3c1881edaae323a4415d3153b5dc11dc6a981c8d1dd93eec8367ceee27b53f8bd27eecbbf66ffcdd04927510c171e7f
languageName: node
linkType: hard

"fs-extra@npm:^10.0.0, fs-extra@npm:^10.1.0":
version: 10.1.0
resolution: "fs-extra@npm:10.1.0"
dependencies:
Expand Down Expand Up @@ -11273,21 +11284,7 @@ __metadata:
languageName: node
linkType: hard

"globby@npm:11.0.4":
version: 11.0.4
resolution: "globby@npm:11.0.4"
dependencies:
array-union: ^2.1.0
dir-glob: ^3.0.1
fast-glob: ^3.1.1
ignore: ^5.1.4
merge2: ^1.3.0
slash: ^3.0.0
checksum: d3e02d5e459e02ffa578b45f040381c33e3c0538ed99b958f0809230c423337999867d7b0dbf752ce93c46157d3bbf154d3fff988a93ccaeb627df8e1841775b
languageName: node
linkType: hard

"globby@npm:^11.0.0, globby@npm:^11.1.0":
"globby@npm:11.1.0, globby@npm:^11.0.0, globby@npm:^11.1.0":
version: 11.1.0
resolution: "globby@npm:11.1.0"
dependencies:
Expand Down Expand Up @@ -11887,7 +11884,7 @@ __metadata:
languageName: node
linkType: hard

"ignore@npm:^5.0.4, ignore@npm:^5.1.1, ignore@npm:^5.1.4, ignore@npm:^5.1.9, ignore@npm:^5.2.0":
"ignore@npm:^5.0.4, ignore@npm:^5.1.1, ignore@npm:^5.1.9, ignore@npm:^5.2.0":
version: 5.2.0
resolution: "ignore@npm:5.2.0"
checksum: 6b1f926792d614f64c6c83da3a1f9c83f6196c2839aa41e1e32dd7b8d174cef2e329d75caabb62cb61ce9dc432f75e67d07d122a037312db7caa73166a1bdb77
Expand Down Expand Up @@ -13498,9 +13495,9 @@ __metadata:
languageName: node
linkType: hard

"knex@npm:2.3.0":
version: 2.3.0
resolution: "knex@npm:2.3.0"
"knex@npm:2.4.0":
version: 2.4.0
resolution: "knex@npm:2.4.0"
dependencies:
colorette: 2.0.19
commander: ^9.1.0
Expand Down Expand Up @@ -13533,7 +13530,7 @@ __metadata:
optional: true
bin:
knex: bin/cli.js
checksum: ec00da6dd622a386507881e9d8ad44b9c5a4d9f272889b181cafb856fd26d7fdb19ef009cecdbbdedaf7c76f985a8fd14348ae47a0bb77b3dbec15f2c03c0dfe
checksum: 66b4ae8412c61125b78512a66d924af95116628e16026efce4d03b80b2ced6b63208b37bb49fb52a499761da5e8981e136b48fcefcd48c3fe9fc72d9d17c5661
languageName: node
linkType: hard

Expand Down Expand Up @@ -14204,10 +14201,10 @@ __metadata:
languageName: node
linkType: hard

"mikro-orm@npm:^5.5.3":
version: 5.5.3
resolution: "mikro-orm@npm:5.5.3"
checksum: 53e86b099870de114d37d239ea14855ffa6da3961afe6af2615884e2fe6edea5ad0eb83f9848c5cca73f587b34c1cf5dbbea47a8990b053a745bc8eb70b89337
"mikro-orm@npm:~5.6.6":
version: 5.6.6
resolution: "mikro-orm@npm:5.6.6"
checksum: 2902d2365af89e019744a9e2ba960251f45a09590aec1e90ee4dcd4c9bc2e37885a67f728f32a1cddac9212d06d51b581c309be7a5d77e2c2e9662c6b2e6aa10
languageName: node
linkType: hard

Expand Down Expand Up @@ -17000,11 +16997,11 @@ __metadata:
"@emotion/babel-plugin": ^11.10.0
"@emotion/react": ^11.4.0
"@emotion/styled": ^11.3.0
"@mikro-orm/better-sqlite": 5.5.3
"@mikro-orm/core": 5.5.3
"@mikro-orm/entity-generator": 5.5.3
"@mikro-orm/migrations": 5.5.3
"@mikro-orm/seeder": 5.5.3
"@mikro-orm/better-sqlite": 5.6.6
"@mikro-orm/core": 5.6.6
"@mikro-orm/entity-generator": 5.6.6
"@mikro-orm/migrations": 5.6.6
"@mikro-orm/seeder": 5.6.6
"@nrwl/cli": ^14.6.3
"@nrwl/cypress": ^14.6.3
"@nrwl/devkit": ^14.6.3
Expand Down

0 comments on commit 3ea36b2

Please sign in to comment.