DenoGres icon indicating copy to clipboard operation
DenoGres copied to clipboard

Can't sync to a fresh database

Open akatechis opened this issue 3 years ago • 4 comments

Following the docs, I'm unable to sync my models to my DB.

I'm starting with a brand new DB, with no tables so I ran denogres --init to bootstrap models in my project. I created models/UserModel.ts with the following:

export interface User {
  id: string;
  email: string;
  name: string;
  passwordHash: string;
  passwordSalt: string;
}

export class UserModel extends Model {
  static table = 'users';
  static columns = {
    id: { type: 'text', primaryKey: true },
    email: { type: 'text', notNull: true },
    name: { type: 'text' },
    passwordHash: { type: 'text', notNull: true },
    passwordSalt: { type: 'text', notNull: true, length: 32 },
  }
}

and then re-export that model in models/model.ts:

export { UserModel } from './UserModel.ts';

Finally, I run denogres --db-sync to create the users table with all the appropriate columns, but I simply get the following error:

> denogres --db-sync
To avoid all potential prompts, please consider running your command with the -x flag.
Sending fatal alert BadCertificate
TLS connection failed with message: invalid peer certificate contents: invalid peer certificate: UnknownIssuer
Defaulting to non-encrypted connection
error: Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'application_name')
        tableListObj[el.table_name][el.column_name] = {
                                                   ^
    at https://deno.land/x/[email protected]/src/functions/introspect.ts:153:52
    at Array.forEach (<anonymous>)
    at introspect (https://deno.land/x/[email protected]/src/functions/introspect.ts:144:14)
    at async sync (https://deno.land/x/[email protected]/src/functions/sync.ts:30:22)

I'm importing from https://deno.land/x/[email protected]/mod.ts, and deno --version prints the following:

> deno --version
deno 1.23.4 (release, x86_64-pc-windows-msvc)
v8 10.4.132.8
typescript 4.7.4

akatechis avatar Oct 18 '22 00:10 akatechis

Same error here

cjroth avatar Dec 29 '22 09:12 cjroth

Did anyone find a solution on this one? 🤔

HelloBanksy avatar Mar 11 '23 16:03 HelloBanksy

Same here

nodgear avatar Apr 18 '23 07:04 nodgear