Skip to content
Discussion options

You must be logged in to vote

For people from the future (and Google).

We can use beforeSchemaInit hook on payload.config.ts:

postgresAdapter({
  pool: {
    connectionString: process.env.DATABASE_URI || '',
  },
  beforeSchemaInit: [
    ({ schema, adapter }) => {
      for (const tableName in adapter.rawTables) {
        const table = adapter.rawTables[tableName]

        for (const fieldName in table.columns) {
          const column = table.columns[fieldName];
          const defaultValue = column?.default ?? '';

          if (defaultValue === 'uuid') {
            delete column.default;

            column.type = 'uuid';
            (column as any).defaultV7 = true;
          }
        }
      }

      return sc…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mariovalney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant