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