Skip to content

Commit

Permalink
feat: fix warning of createTableIfNotExists() (#29)
Browse files Browse the repository at this point in the history
* chore: fix deprecation warning

* Update package-lock.json

* chore: correct query implementation

---------

Co-authored-by: hsluoyz <[email protected]>
  • Loading branch information
luke88jones and hsluoyz authored Jan 31, 2024
1 parent b53570a commit a14f431
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,14 @@ export class BasicAdapter<T extends keyof Instance> implements Adapter {
}

private async createTable(): Promise<void> {
const tableExists = await this.query(
this.knex.schema.hasTable(CasbinRuleTable).toString(),
);

if (tableExists.length > 0) return;

const createTableSQL = this.knex.schema
.createTableIfNotExists(CasbinRuleTable, (table) => {
.createTable(CasbinRuleTable, (table) => {
table.increments();
table.string('ptype').notNullable();
for (const i of ['v0', 'v1', 'v2', 'v3', 'v4', 'v5']) {
Expand Down

0 comments on commit a14f431

Please sign in to comment.