orchid-orm 1.47.1 → 1.49.0

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.
@@ -119,7 +119,11 @@ const checkForColumnAddOrDrop = (shape, key) => {
119
119
  return false;
120
120
  };
121
121
 
122
- const processSchemas = async (ast, schemas, dbStructure, verifying) => {
122
+ const processSchemas = async (ast, dbStructure, {
123
+ codeItems: { schemas },
124
+ verifying,
125
+ internal: { generatorIgnore }
126
+ }) => {
123
127
  const createSchemas = [];
124
128
  const dropSchemas = [];
125
129
  for (const schema of schemas) {
@@ -128,7 +132,7 @@ const processSchemas = async (ast, schemas, dbStructure, verifying) => {
128
132
  }
129
133
  }
130
134
  for (const schema of dbStructure.schemas) {
131
- if (!schemas.has(schema) && schema !== "public") {
135
+ if (!schemas.has(schema) && schema !== "public" && !generatorIgnore?.schemas?.includes(schema)) {
132
136
  dropSchemas.push(schema);
133
137
  }
134
138
  }
@@ -189,12 +193,18 @@ const renameSchemaInStructures = (items, from, to) => {
189
193
  }
190
194
  };
191
195
 
192
- const processExtensions = (ast, dbStructure, currentSchema, extensions) => {
196
+ const processExtensions = (ast, dbStructure, {
197
+ currentSchema,
198
+ internal: { extensions, generatorIgnore }
199
+ }) => {
193
200
  const codeExtensions = extensions?.map((ext) => {
194
201
  const [schema, name] = getSchemaAndTableFromName(ext.name);
195
202
  return { schema, name, version: ext.version };
196
203
  });
197
204
  for (const dbExt of dbStructure.extensions) {
205
+ if (generatorIgnore?.schemas?.includes(dbExt.schemaName) || generatorIgnore?.extensions?.includes(dbExt.name)) {
206
+ continue;
207
+ }
198
208
  if (codeExtensions) {
199
209
  let found = false;
200
210
  for (let i = 0; i < codeExtensions.length; i++) {
@@ -593,7 +603,12 @@ const renameColumn = (columns, from, to) => {
593
603
  }
594
604
  };
595
605
 
596
- const processDomains = async (ast, adapter, structureToAstCtx, domainsMap, dbStructure, currentSchema, domains) => {
606
+ const processDomains = async (ast, adapter, domainsMap, dbStructure, {
607
+ codeItems: { domains },
608
+ structureToAstCtx,
609
+ currentSchema,
610
+ internal: { generatorIgnore }
611
+ }) => {
597
612
  const codeDomains = [];
598
613
  if (domains) {
599
614
  for (const { schemaName, name, column } of domains) {
@@ -605,6 +620,9 @@ const processDomains = async (ast, adapter, structureToAstCtx, domainsMap, dbStr
605
620
  const tableExpressions = [];
606
621
  const holdCodeDomains = /* @__PURE__ */ new Set();
607
622
  for (const domain of dbStructure.domains) {
623
+ if (generatorIgnore?.schemas?.includes(domain.schemaName) || generatorIgnore?.domains?.includes(domain.name)) {
624
+ continue;
625
+ }
608
626
  const dbColumn = instantiateDbColumn(
609
627
  structureToAstCtx,
610
628
  dbStructure,
@@ -770,7 +788,12 @@ const createAst = (codeDomain) => ({
770
788
  baseType: codeDomain.column
771
789
  });
772
790
 
773
- const processEnums = async (ast, enums, dbStructure, currentSchema, verifying) => {
791
+ const processEnums = async (ast, dbStructure, {
792
+ codeItems: { enums },
793
+ currentSchema,
794
+ verifying,
795
+ internal: { generatorIgnore }
796
+ }) => {
774
797
  const createEnums = [];
775
798
  const dropEnums = [];
776
799
  for (const [, codeEnum] of enums) {
@@ -783,6 +806,9 @@ const processEnums = async (ast, enums, dbStructure, currentSchema, verifying) =
783
806
  }
784
807
  }
785
808
  for (const dbEnum of dbStructure.enums) {
809
+ if (generatorIgnore?.schemas?.includes(dbEnum.schemaName) || generatorIgnore?.enums?.includes(dbEnum.name)) {
810
+ continue;
811
+ }
786
812
  const codeEnum = enums.get(`${dbEnum.schemaName}.${dbEnum.name}`);
787
813
  if (codeEnum) {
788
814
  changeEnum(ast, dbEnum, codeEnum);
@@ -1784,7 +1810,13 @@ const dropCheck = ({ changeTableAst: { drop }, changingColumns }, dbCheck, name)
1784
1810
  }
1785
1811
  };
1786
1812
 
1787
- const processTables = async (ast, structureToAstCtx, domainsMap, adapter, tables, dbStructure, currentSchema, config, generatorIgnore, verifying) => {
1813
+ const processTables = async (ast, domainsMap, adapter, dbStructure, config, {
1814
+ structureToAstCtx,
1815
+ codeItems: { tables },
1816
+ currentSchema,
1817
+ internal: { generatorIgnore },
1818
+ verifying
1819
+ }) => {
1788
1820
  const createTables = collectCreateTables(
1789
1821
  tables,
1790
1822
  dbStructure,
@@ -1857,7 +1889,7 @@ const collectChangeAndDropTables = (config, tables, dbStructure, currentSchema,
1857
1889
  return { schema, table };
1858
1890
  });
1859
1891
  for (const dbTable of dbStructure.tables) {
1860
- if (dbTable.name === config.migrationsTable || ignoreTables?.some(
1892
+ if (dbTable.name === config.migrationsTable || generatorIgnore?.schemas?.includes(dbTable.schemaName) || ignoreTables?.some(
1861
1893
  ({ schema, table }) => table === dbTable.name && schema === dbTable.schemaName
1862
1894
  ))
1863
1895
  continue;
@@ -2071,38 +2103,14 @@ const processTableChange = async (adapter, structureToAstCtx, dbStructure, domai
2071
2103
  }
2072
2104
  };
2073
2105
 
2074
- const composeMigration = async (adapter, config, ast, dbStructure, {
2075
- structureToAstCtx,
2076
- codeItems: { schemas, enums, tables, domains },
2077
- currentSchema,
2078
- internal,
2079
- verifying
2080
- }) => {
2106
+ const composeMigration = async (adapter, config, ast, dbStructure, params) => {
2107
+ const { structureToAstCtx, currentSchema } = params;
2081
2108
  const domainsMap = makeDomainsMap(structureToAstCtx, dbStructure);
2082
- await processSchemas(ast, schemas, dbStructure, verifying);
2083
- processExtensions(ast, dbStructure, currentSchema, internal.extensions);
2084
- await processDomains(
2085
- ast,
2086
- adapter,
2087
- structureToAstCtx,
2088
- domainsMap,
2089
- dbStructure,
2090
- currentSchema,
2091
- domains
2092
- );
2093
- await processEnums(ast, enums, dbStructure, currentSchema, verifying);
2094
- await processTables(
2095
- ast,
2096
- structureToAstCtx,
2097
- domainsMap,
2098
- adapter,
2099
- tables,
2100
- dbStructure,
2101
- currentSchema,
2102
- config,
2103
- internal.generatorIgnore,
2104
- verifying
2105
- );
2109
+ await processSchemas(ast, dbStructure, params);
2110
+ processExtensions(ast, dbStructure, params);
2111
+ await processDomains(ast, adapter, domainsMap, dbStructure, params);
2112
+ await processEnums(ast, dbStructure, params);
2113
+ await processTables(ast, domainsMap, adapter, dbStructure, config, params);
2106
2114
  return astToMigration(currentSchema, config, ast);
2107
2115
  };
2108
2116