rake-db 2.25.7 → 2.25.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2479,6 +2479,7 @@ const changeEnumValues = async (migration, enumName, fromValues, toValues) => {
2479
2479
  const recreateEnum = async (migration, { schema, name }, values, errorMessage) => {
2480
2480
  const defaultSchema = migration.adapter.schema;
2481
2481
  const quotedName = quoteTable(schema, name);
2482
+ const relKinds = ["r", "m"];
2482
2483
  const { rows: tables } = await migration.adapter.query(
2483
2484
  `SELECT n.nspname AS "schema",
2484
2485
  c.relname AS "table",
@@ -2490,6 +2491,7 @@ JOIN pg_type t ON a.atttypid = t.oid AND t.typname = ${orchidCore.singleQuote(na
2490
2491
  JOIN pg_namespace tn ON tn.oid = t.typnamespace AND tn.nspname = ${orchidCore.singleQuote(
2491
2492
  schema ?? defaultSchema
2492
2493
  )}
2494
+ WHERE c.relkind IN (${relKinds.map((c) => `'${c}'`).join(", ")})
2493
2495
  GROUP BY n.nspname, c.relname`
2494
2496
  );
2495
2497
  const sql = tables.map(
@@ -4852,14 +4854,16 @@ const astToMigration = (currentSchema, config, asts) => {
4852
4854
  const item = items[i];
4853
4855
  let satisfied = true;
4854
4856
  for (const dep of item.deps) {
4855
- if (toBeAdded.has(dep) && !added.has(dep)) {
4857
+ if (toBeAdded.has(dep) && !added.has(dep) && !item.add.has(dep)) {
4856
4858
  satisfied = false;
4857
4859
  break;
4858
4860
  }
4859
4861
  }
4860
4862
  if (satisfied) {
4861
- for (const key of item.drop) {
4862
- if (remainingDeps.has(key)) {
4863
+ for (const dep of item.drop) {
4864
+ const selfRef = item.deps.has(dep);
4865
+ const depsLeft = remainingDeps.get(dep);
4866
+ if (depsLeft && depsLeft > (selfRef ? 1 : 0)) {
4863
4867
  satisfied = false;
4864
4868
  break;
4865
4869
  }