Skip to content

Commit

Permalink
tidy config reloader
Browse files Browse the repository at this point in the history
  • Loading branch information
prostgles committed Dec 2, 2024
1 parent 8100d24 commit 14de568
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions lib/TableConfig/initTableConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export const initTableConfig = async function (this: TableConfigurator<any>) {
if (this.prostgles.opts.tableConfigMigrations) {
const { onMigrate, version, versionTableName = "schema_version" } = this.prostgles.opts.tableConfigMigrations;
await this.db.any(`
/* ${PubSubManager.EXCLUDE_QUERY_FROM_SCHEMA_WATCH_ID} */
CREATE TABLE IF NOT EXISTS ${asName(versionTableName)}(id NUMERIC PRIMARY KEY, table_config JSONB NOT NULL)
`);
/* ${PubSubManager.EXCLUDE_QUERY_FROM_SCHEMA_WATCH_ID} */
CREATE TABLE IF NOT EXISTS ${asName(versionTableName)}(id NUMERIC PRIMARY KEY, table_config JSONB NOT NULL)
`);
migrations = { version, table: versionTableName };
let latestVersion: number | undefined;
try {
latestVersion = Number((await this.db.oneOrNone(`SELECT MAX(id) as v FROM ${asName(versionTableName)}`)).v);
} catch (e) {
} catch (_e) {

}

Expand Down
4 changes: 1 addition & 3 deletions lib/initProstgles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const initProstgles = async function(this: Prostgles, onReady: OnReadyCal
/* 5. Finish init and provide DBO object */
try {
if (this.destroyed) {
console.trace(1)
console.trace("Prostgles: Instance is destroyed")
}
onReady({
dbo: this.dbo as any,
Expand Down Expand Up @@ -186,10 +186,8 @@ export const initProstgles = async function(this: Prostgles, onReady: OnReadyCal
}
if("tableConfig" in newOpts){
await this.initTableConfig({ type: "prgl.update", newOpts });
await this.refreshDBO();
}
if("schema" in newOpts){
await this.initTableConfig({ type: "prgl.update", newOpts });
await this.refreshDBO();
}
if("auth" in newOpts){
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prostgles-server",
"version": "4.2.171",
"version": "4.2.172",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion tests/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 14de568

Please sign in to comment.