drizzle-kit 0.28.0 → 0.28.1-14e59f4

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/README.md CHANGED
@@ -1,21 +1,21 @@
1
1
  ## Drizzle Kit
2
2
 
3
- DrizzleKit - is a CLI migrator tool for DrizzleORM. It is probably one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like deletions and renames by prompting user input.
3
+ Drizzle Kit is a CLI migrator tool for Drizzle ORM. It is probably the one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like deletions and renames by prompting user input.
4
4
  <https://github.com/drizzle-team/drizzle-kit-mirror> - is a mirror repository for issues.
5
5
 
6
6
  ## Documentation
7
7
 
8
- Check the full documenation on [the website](https://orm.drizzle.team/kit-docs/overview)
8
+ Check the full documentation on [the website](https://orm.drizzle.team/kit-docs/overview).
9
9
 
10
10
  ### How it works
11
11
 
12
- `drizzle-kit` will traverse `schema folder` or `schema file`, generate schema snapshot and compare it to the previous version, if there's one.
13
- Based on the difference it will generate all needed SQL migrations and if there are any `automatically unresolvable` cases like `renames` it will prompt user for input.
12
+ Drizzle Kit traverses a schema module and generates a snapshot to compare with the previous version, if there is one.
13
+ Based on the difference, it will generate all needed SQL migrations. If there are any cases that can't be resolved automatically, such as renames, it will prompt the user for input.
14
14
 
15
- For schema file:
15
+ For example, for this schema module:
16
16
 
17
17
  ```typescript
18
- // ./src/db/schema.ts
18
+ // src/db/schema.ts
19
19
 
20
20
  import { integer, pgTable, serial, text, varchar } from "drizzle-orm/pg-core";
21
21
 
@@ -63,7 +63,7 @@ CREATE INDEX IF NOT EXISTS users_full_name_index ON users (full_name);
63
63
  npm install -D drizzle-kit
64
64
  ```
65
65
 
66
- Running with CLI options
66
+ Running with CLI options:
67
67
 
68
68
  ```jsonc
69
69
  // package.json
package/api.d.mts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { LibSQLDatabase } from 'drizzle-orm/libsql';
2
2
  import { MySql2Database } from 'drizzle-orm/mysql2';
3
3
  import { PgDatabase } from 'drizzle-orm/pg-core';
4
- import { C as CasingType, a as Config } from './index-BfiZoTqG.mjs';
4
+ import { SingleStoreDriverDatabase } from 'drizzle-orm/singlestore';
5
+ import { C as CasingType, a as Config } from './index-Z-1TKnbX.mjs';
5
6
  import * as zod from 'zod';
6
7
  import { TypeOf } from 'zod';
7
8
  import 'tls';
8
9
 
9
- declare const schema$1: zod.ZodObject<zod.objectUtil.extendShape<{
10
+ declare const schema$2: zod.ZodObject<zod.objectUtil.extendShape<{
10
11
  version: zod.ZodLiteral<"5">;
11
12
  dialect: zod.ZodLiteral<"mysql">;
12
13
  tables: zod.ZodRecord<zod.ZodString, zod.ZodObject<{
@@ -558,7 +559,7 @@ declare const schema$1: zod.ZodObject<zod.objectUtil.extendShape<{
558
559
  definition?: string | undefined;
559
560
  }> | undefined;
560
561
  }>;
561
- type MySqlSchema = TypeOf<typeof schema$1>;
562
+ type MySqlSchema = TypeOf<typeof schema$2>;
562
563
 
563
564
  declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
564
565
  version: zod.ZodLiteral<"7">;
@@ -1805,6 +1806,339 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1805
1806
  }>;
1806
1807
  type PgSchema = TypeOf<typeof pgSchema>;
1807
1808
 
1809
+ declare const schema$1: zod.ZodObject<zod.objectUtil.extendShape<{
1810
+ version: zod.ZodLiteral<"1">;
1811
+ dialect: zod.ZodLiteral<"singlestore">;
1812
+ tables: zod.ZodRecord<zod.ZodString, zod.ZodObject<{
1813
+ name: zod.ZodString;
1814
+ columns: zod.ZodRecord<zod.ZodString, zod.ZodObject<{
1815
+ name: zod.ZodString;
1816
+ type: zod.ZodString;
1817
+ primaryKey: zod.ZodBoolean;
1818
+ notNull: zod.ZodBoolean;
1819
+ autoincrement: zod.ZodOptional<zod.ZodBoolean>;
1820
+ default: zod.ZodOptional<zod.ZodAny>;
1821
+ onUpdate: zod.ZodOptional<zod.ZodAny>;
1822
+ generated: zod.ZodOptional<zod.ZodObject<{
1823
+ type: zod.ZodEnum<["stored", "virtual"]>;
1824
+ as: zod.ZodString;
1825
+ }, "strip", zod.ZodTypeAny, {
1826
+ type: "stored" | "virtual";
1827
+ as: string;
1828
+ }, {
1829
+ type: "stored" | "virtual";
1830
+ as: string;
1831
+ }>>;
1832
+ }, "strict", zod.ZodTypeAny, {
1833
+ name: string;
1834
+ type: string;
1835
+ primaryKey: boolean;
1836
+ notNull: boolean;
1837
+ default?: any;
1838
+ onUpdate?: any;
1839
+ autoincrement?: boolean | undefined;
1840
+ generated?: {
1841
+ type: "stored" | "virtual";
1842
+ as: string;
1843
+ } | undefined;
1844
+ }, {
1845
+ name: string;
1846
+ type: string;
1847
+ primaryKey: boolean;
1848
+ notNull: boolean;
1849
+ default?: any;
1850
+ onUpdate?: any;
1851
+ autoincrement?: boolean | undefined;
1852
+ generated?: {
1853
+ type: "stored" | "virtual";
1854
+ as: string;
1855
+ } | undefined;
1856
+ }>>;
1857
+ indexes: zod.ZodRecord<zod.ZodString, zod.ZodObject<{
1858
+ name: zod.ZodString;
1859
+ columns: zod.ZodArray<zod.ZodString, "many">;
1860
+ isUnique: zod.ZodBoolean;
1861
+ using: zod.ZodOptional<zod.ZodEnum<["btree", "hash"]>>;
1862
+ algorithm: zod.ZodOptional<zod.ZodEnum<["default", "inplace", "copy"]>>;
1863
+ lock: zod.ZodOptional<zod.ZodEnum<["default", "none", "shared", "exclusive"]>>;
1864
+ }, "strict", zod.ZodTypeAny, {
1865
+ name: string;
1866
+ columns: string[];
1867
+ isUnique: boolean;
1868
+ using?: "btree" | "hash" | undefined;
1869
+ algorithm?: "default" | "inplace" | "copy" | undefined;
1870
+ lock?: "none" | "default" | "shared" | "exclusive" | undefined;
1871
+ }, {
1872
+ name: string;
1873
+ columns: string[];
1874
+ isUnique: boolean;
1875
+ using?: "btree" | "hash" | undefined;
1876
+ algorithm?: "default" | "inplace" | "copy" | undefined;
1877
+ lock?: "none" | "default" | "shared" | "exclusive" | undefined;
1878
+ }>>;
1879
+ compositePrimaryKeys: zod.ZodRecord<zod.ZodString, zod.ZodObject<{
1880
+ name: zod.ZodString;
1881
+ columns: zod.ZodArray<zod.ZodString, "many">;
1882
+ }, "strict", zod.ZodTypeAny, {
1883
+ name: string;
1884
+ columns: string[];
1885
+ }, {
1886
+ name: string;
1887
+ columns: string[];
1888
+ }>>;
1889
+ uniqueConstraints: zod.ZodDefault<zod.ZodRecord<zod.ZodString, zod.ZodObject<{
1890
+ name: zod.ZodString;
1891
+ columns: zod.ZodArray<zod.ZodString, "many">;
1892
+ }, "strict", zod.ZodTypeAny, {
1893
+ name: string;
1894
+ columns: string[];
1895
+ }, {
1896
+ name: string;
1897
+ columns: string[];
1898
+ }>>>;
1899
+ }, "strict", zod.ZodTypeAny, {
1900
+ name: string;
1901
+ columns: Record<string, {
1902
+ name: string;
1903
+ type: string;
1904
+ primaryKey: boolean;
1905
+ notNull: boolean;
1906
+ default?: any;
1907
+ onUpdate?: any;
1908
+ autoincrement?: boolean | undefined;
1909
+ generated?: {
1910
+ type: "stored" | "virtual";
1911
+ as: string;
1912
+ } | undefined;
1913
+ }>;
1914
+ indexes: Record<string, {
1915
+ name: string;
1916
+ columns: string[];
1917
+ isUnique: boolean;
1918
+ using?: "btree" | "hash" | undefined;
1919
+ algorithm?: "default" | "inplace" | "copy" | undefined;
1920
+ lock?: "none" | "default" | "shared" | "exclusive" | undefined;
1921
+ }>;
1922
+ compositePrimaryKeys: Record<string, {
1923
+ name: string;
1924
+ columns: string[];
1925
+ }>;
1926
+ uniqueConstraints: Record<string, {
1927
+ name: string;
1928
+ columns: string[];
1929
+ }>;
1930
+ }, {
1931
+ name: string;
1932
+ columns: Record<string, {
1933
+ name: string;
1934
+ type: string;
1935
+ primaryKey: boolean;
1936
+ notNull: boolean;
1937
+ default?: any;
1938
+ onUpdate?: any;
1939
+ autoincrement?: boolean | undefined;
1940
+ generated?: {
1941
+ type: "stored" | "virtual";
1942
+ as: string;
1943
+ } | undefined;
1944
+ }>;
1945
+ indexes: Record<string, {
1946
+ name: string;
1947
+ columns: string[];
1948
+ isUnique: boolean;
1949
+ using?: "btree" | "hash" | undefined;
1950
+ algorithm?: "default" | "inplace" | "copy" | undefined;
1951
+ lock?: "none" | "default" | "shared" | "exclusive" | undefined;
1952
+ }>;
1953
+ compositePrimaryKeys: Record<string, {
1954
+ name: string;
1955
+ columns: string[];
1956
+ }>;
1957
+ uniqueConstraints?: Record<string, {
1958
+ name: string;
1959
+ columns: string[];
1960
+ }> | undefined;
1961
+ }>>;
1962
+ _meta: zod.ZodObject<{
1963
+ tables: zod.ZodRecord<zod.ZodString, zod.ZodString>;
1964
+ columns: zod.ZodRecord<zod.ZodString, zod.ZodString>;
1965
+ }, "strip", zod.ZodTypeAny, {
1966
+ columns: Record<string, string>;
1967
+ tables: Record<string, string>;
1968
+ }, {
1969
+ columns: Record<string, string>;
1970
+ tables: Record<string, string>;
1971
+ }>;
1972
+ internal: zod.ZodOptional<zod.ZodObject<{
1973
+ tables: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodOptional<zod.ZodObject<{
1974
+ columns: zod.ZodRecord<zod.ZodString, zod.ZodOptional<zod.ZodObject<{
1975
+ isDefaultAnExpression: zod.ZodOptional<zod.ZodBoolean>;
1976
+ }, "strip", zod.ZodTypeAny, {
1977
+ isDefaultAnExpression?: boolean | undefined;
1978
+ }, {
1979
+ isDefaultAnExpression?: boolean | undefined;
1980
+ }>>>;
1981
+ }, "strip", zod.ZodTypeAny, {
1982
+ columns: Record<string, {
1983
+ isDefaultAnExpression?: boolean | undefined;
1984
+ } | undefined>;
1985
+ }, {
1986
+ columns: Record<string, {
1987
+ isDefaultAnExpression?: boolean | undefined;
1988
+ } | undefined>;
1989
+ }>>>>;
1990
+ indexes: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodOptional<zod.ZodObject<{
1991
+ columns: zod.ZodRecord<zod.ZodString, zod.ZodOptional<zod.ZodObject<{
1992
+ isExpression: zod.ZodOptional<zod.ZodBoolean>;
1993
+ }, "strip", zod.ZodTypeAny, {
1994
+ isExpression?: boolean | undefined;
1995
+ }, {
1996
+ isExpression?: boolean | undefined;
1997
+ }>>>;
1998
+ }, "strip", zod.ZodTypeAny, {
1999
+ columns: Record<string, {
2000
+ isExpression?: boolean | undefined;
2001
+ } | undefined>;
2002
+ }, {
2003
+ columns: Record<string, {
2004
+ isExpression?: boolean | undefined;
2005
+ } | undefined>;
2006
+ }>>>>;
2007
+ }, "strip", zod.ZodTypeAny, {
2008
+ indexes?: Record<string, {
2009
+ columns: Record<string, {
2010
+ isExpression?: boolean | undefined;
2011
+ } | undefined>;
2012
+ } | undefined> | undefined;
2013
+ tables?: Record<string, {
2014
+ columns: Record<string, {
2015
+ isDefaultAnExpression?: boolean | undefined;
2016
+ } | undefined>;
2017
+ } | undefined> | undefined;
2018
+ }, {
2019
+ indexes?: Record<string, {
2020
+ columns: Record<string, {
2021
+ isExpression?: boolean | undefined;
2022
+ } | undefined>;
2023
+ } | undefined> | undefined;
2024
+ tables?: Record<string, {
2025
+ columns: Record<string, {
2026
+ isDefaultAnExpression?: boolean | undefined;
2027
+ } | undefined>;
2028
+ } | undefined> | undefined;
2029
+ }>>;
2030
+ }, {
2031
+ id: zod.ZodString;
2032
+ prevId: zod.ZodString;
2033
+ }>, "strip", zod.ZodTypeAny, {
2034
+ tables: Record<string, {
2035
+ name: string;
2036
+ columns: Record<string, {
2037
+ name: string;
2038
+ type: string;
2039
+ primaryKey: boolean;
2040
+ notNull: boolean;
2041
+ default?: any;
2042
+ onUpdate?: any;
2043
+ autoincrement?: boolean | undefined;
2044
+ generated?: {
2045
+ type: "stored" | "virtual";
2046
+ as: string;
2047
+ } | undefined;
2048
+ }>;
2049
+ indexes: Record<string, {
2050
+ name: string;
2051
+ columns: string[];
2052
+ isUnique: boolean;
2053
+ using?: "btree" | "hash" | undefined;
2054
+ algorithm?: "default" | "inplace" | "copy" | undefined;
2055
+ lock?: "none" | "default" | "shared" | "exclusive" | undefined;
2056
+ }>;
2057
+ compositePrimaryKeys: Record<string, {
2058
+ name: string;
2059
+ columns: string[];
2060
+ }>;
2061
+ uniqueConstraints: Record<string, {
2062
+ name: string;
2063
+ columns: string[];
2064
+ }>;
2065
+ }>;
2066
+ id: string;
2067
+ prevId: string;
2068
+ version: "1";
2069
+ dialect: "singlestore";
2070
+ _meta: {
2071
+ columns: Record<string, string>;
2072
+ tables: Record<string, string>;
2073
+ };
2074
+ internal?: {
2075
+ indexes?: Record<string, {
2076
+ columns: Record<string, {
2077
+ isExpression?: boolean | undefined;
2078
+ } | undefined>;
2079
+ } | undefined> | undefined;
2080
+ tables?: Record<string, {
2081
+ columns: Record<string, {
2082
+ isDefaultAnExpression?: boolean | undefined;
2083
+ } | undefined>;
2084
+ } | undefined> | undefined;
2085
+ } | undefined;
2086
+ }, {
2087
+ tables: Record<string, {
2088
+ name: string;
2089
+ columns: Record<string, {
2090
+ name: string;
2091
+ type: string;
2092
+ primaryKey: boolean;
2093
+ notNull: boolean;
2094
+ default?: any;
2095
+ onUpdate?: any;
2096
+ autoincrement?: boolean | undefined;
2097
+ generated?: {
2098
+ type: "stored" | "virtual";
2099
+ as: string;
2100
+ } | undefined;
2101
+ }>;
2102
+ indexes: Record<string, {
2103
+ name: string;
2104
+ columns: string[];
2105
+ isUnique: boolean;
2106
+ using?: "btree" | "hash" | undefined;
2107
+ algorithm?: "default" | "inplace" | "copy" | undefined;
2108
+ lock?: "none" | "default" | "shared" | "exclusive" | undefined;
2109
+ }>;
2110
+ compositePrimaryKeys: Record<string, {
2111
+ name: string;
2112
+ columns: string[];
2113
+ }>;
2114
+ uniqueConstraints?: Record<string, {
2115
+ name: string;
2116
+ columns: string[];
2117
+ }> | undefined;
2118
+ }>;
2119
+ id: string;
2120
+ prevId: string;
2121
+ version: "1";
2122
+ dialect: "singlestore";
2123
+ _meta: {
2124
+ columns: Record<string, string>;
2125
+ tables: Record<string, string>;
2126
+ };
2127
+ internal?: {
2128
+ indexes?: Record<string, {
2129
+ columns: Record<string, {
2130
+ isExpression?: boolean | undefined;
2131
+ } | undefined>;
2132
+ } | undefined> | undefined;
2133
+ tables?: Record<string, {
2134
+ columns: Record<string, {
2135
+ isDefaultAnExpression?: boolean | undefined;
2136
+ } | undefined>;
2137
+ } | undefined> | undefined;
2138
+ } | undefined;
2139
+ }>;
2140
+ type SingleStoreSchema = TypeOf<typeof schema$1>;
2141
+
1808
2142
  declare const schema: zod.ZodObject<zod.objectUtil.extendShape<{
1809
2143
  version: zod.ZodLiteral<"6">;
1810
2144
  dialect: zod.ZodEnum<["sqlite"]>;
@@ -2284,6 +2618,7 @@ type SQLiteSchema = TypeOf<typeof schema>;
2284
2618
  type DrizzleSnapshotJSON = PgSchema;
2285
2619
  type DrizzleSQLiteSnapshotJSON = SQLiteSchema;
2286
2620
  type DrizzleMySQLSnapshotJSON = MySqlSchema;
2621
+ type DrizzleSingleStoreSnapshotJSON = SingleStoreSchema;
2287
2622
  declare const generateDrizzleJson: (imports: Record<string, unknown>, prevId?: string, schemaFilters?: string[], casing?: CasingType) => PgSchema;
2288
2623
  declare const generateMigration: (prev: DrizzleSnapshotJSON, cur: DrizzleSnapshotJSON) => Promise<string[]>;
2289
2624
  declare const pushSchema: (imports: Record<string, unknown>, drizzleInstance: PgDatabase<any>, schemaFilters?: string[], tablesFilter?: string[], extensionsFilters?: Config["extensionsFilters"]) => Promise<{
@@ -2308,6 +2643,14 @@ declare const pushMySQLSchema: (imports: Record<string, unknown>, drizzleInstanc
2308
2643
  statementsToExecute: string[];
2309
2644
  apply: () => Promise<void>;
2310
2645
  }>;
2646
+ declare const generateSingleStoreDrizzleJson: (imports: Record<string, unknown>, prevId?: string, casing?: CasingType) => Promise<SingleStoreSchema>;
2647
+ declare const generateSingleStoreMigration: (prev: DrizzleSingleStoreSnapshotJSON, cur: DrizzleSingleStoreSnapshotJSON) => Promise<string[]>;
2648
+ declare const pushSingleStoreSchema: (imports: Record<string, unknown>, drizzleInstance: SingleStoreDriverDatabase<any>, databaseName: string) => Promise<{
2649
+ hasDataLoss: boolean;
2650
+ warnings: string[];
2651
+ statementsToExecute: string[];
2652
+ apply: () => Promise<void>;
2653
+ }>;
2311
2654
  declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
2312
2655
  version: "7";
2313
2656
  dialect: "postgresql";
@@ -2500,4 +2843,4 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
2500
2843
  } | undefined;
2501
2844
  } | Record<string, unknown>;
2502
2845
 
2503
- export { type DrizzleMySQLSnapshotJSON, type DrizzleSQLiteSnapshotJSON, type DrizzleSnapshotJSON, generateDrizzleJson, generateMigration, generateMySQLDrizzleJson, generateMySQLMigration, generateSQLiteDrizzleJson, generateSQLiteMigration, pushMySQLSchema, pushSQLiteSchema, pushSchema, upPgSnapshot };
2846
+ export { type DrizzleMySQLSnapshotJSON, type DrizzleSQLiteSnapshotJSON, type DrizzleSingleStoreSnapshotJSON, type DrizzleSnapshotJSON, generateDrizzleJson, generateMigration, generateMySQLDrizzleJson, generateMySQLMigration, generateSQLiteDrizzleJson, generateSQLiteMigration, generateSingleStoreDrizzleJson, generateSingleStoreMigration, pushMySQLSchema, pushSQLiteSchema, pushSchema, pushSingleStoreSchema, upPgSnapshot };