Skip to content

Can't sync to a fresh database #63

@akatechis

Description

@akatechis

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/denogres@v2.0/src/functions/introspect.ts:153:52
    at Array.forEach (<anonymous>)
    at introspect (https://deno.land/x/denogres@v2.0/src/functions/introspect.ts:144:14)
    at async sync (https://deno.land/x/denogres@v2.0/src/functions/sync.ts:30:22)

I'm importing from https://deno.land/x/denogres@v2.0/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions