kristiandupont/extract-pg-schema

Issue with PgType name

Closed this issue · 3 comments

We're upgrading from 4.6.0 to 4.7.0.

We just extracted the database and compare them to last Jest snapshots:

const schemas = await extractSchemas(connectionString, { schemas: schemaNames })
expect(schemas).toMatchSnapshot()

Looks like, the hash column names are different from environments.
Because, the tests were passed in dev environments.
However, failed in Github CI. 🤷

Object {
            "columns": Array [
              Object {
                "definition": "updated_at",
                "name": "updated_at",
              },
            ],
            "isPrimary": false,
            "isUnique": false,
    -       "name": "913aaa3e6dc3acb0e5c8756bb794240b",
    +       "name": "710005f92666ce4905b33a2fe7de36db",
          },

This didn't happen to us in 4.6.0.

Any idea?

Hm, I am not completely sure what I am looking at here. What are "the hash column names"? Do you mean indices?
If so, what creates the names of your indices?

There was a recent PR (#483) that made sure indices are not referenced between schemas, so that might be related but I am not sure..

Sorry for confusing.

It's exactly a PgType name:

/**
* Base type for Postgres objects.
*/
type PgType<K extends Kind = Kind> = {
/**
* The name of the object.
*/
name: string;
/**
* The name of the schema that the object is in.
*/
schemaName: string;
/**
* The kind of the object.
*/
kind: K;
/**
* The comment on the object, if any.
*/
comment: string | null;
};

I think they are generated randomly or somehow?
Because we got different names from our environments.

I'm sorry but I don't really have any ideas. If you can provide me with more information, maybe it can help. This library does not generate any hashes or strings like those (not that I can recall anyway), so my best guess is that you have something that creates them somewhere. Why you are only seeing this now I don't know.