drizzle-team / drizzle-kit-mirror

Docs and issues repository for drizzle-kit
289 stars 17 forks source link

Allow absolute path to migration output directory #81

Open namdien177 opened 1 year ago

namdien177 commented 1 year ago

I'm working on a project containing many custom CLI tooling to trigger different CLI commands from different libraries. To have the most reliable file path to execute, we will normally use absolute paths for all configs.

With that said, Drizzle-ORM Kit is currently auto-adding a relative prefix path (./) to the config path without checking whether it is absolute or not when using drizzle-kit generate:mysql command. We can have a workaround to modify our custom CLI to handle this library specifically but it would be best to have the kit to handle it automatically.

Another reason is, the same absolute path in the migrate function (provided by drizzle-orm/<provider>/migrator) will work perfectly fine. It's better to have this behavior consistent.

The idea can be: checking if the path provided is a valid "absolute" path, or will add the prefix afterward.

Below is the current behavior.

image

zsolt-dev commented 1 year ago

Hi,

I am hitting the same issue.

This is the workaround:


// Remove after this bug is fixed: https://github.com/drizzle-team/drizzle-kit-mirror/issues/81
const migrationsRelativePath = path.relative(process.cwd(), migrationsPath);

export default {
  schema: schemaPath,
  out: migrationsRelativePath,
  driver: 'pg',
  dbCredentials: {
    connectionString,
  },
} satisfies Config;
arily commented 6 months ago

migration (drizzle-kit generate) won't work.

fcanela commented 4 months ago

I found this issue after being affected by the same behavior. While it is easy to fix, it is also a bad surprise.