hysteria-orm 10.5.6 → 10.5.8

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/lib/index.d.cts CHANGED
@@ -764,6 +764,122 @@ type ForeignKeyOptions = CommonConstraintOptions & {
764
764
  };
765
765
  type CreateTableContext = "alter_table" | "create_table";
766
766
  type CommonPostgresExtensions = "postgis" | "uuid-ossp" | "hstore" | "pg_trgm" | "btree_gin" | "btree_gist" | "citext" | "pgcrypto" | "tablefunc" | "unaccent" | "pg_stat_statements" | "ltree" | "cube" | "earthdistance" | "fuzzystrmatch" | "intarray" | "isn" | "lo" | "pg_buffercache" | "pgrowlocks" | "pgstattuple" | "pg_freespacemap" | "postgres_fdw" | "seg" | "tsm_system_rows" | "tsm_system_time" | "plpgsql" | "plperl" | "plpython3u" | "pltcl" | "adminpack" | "amcheck" | "autoinc" | "bloom" | "dict_int" | "dict_xsyn" | "file_fdw" | "insert_username" | "intagg" | "moddatetime" | "old_snapshot" | "pageinspect" | "pg_prewarm" | "pg_surgery" | "pg_visibility" | "pgaudit" | "pglogical" | "pgrouting" | "postgis_topology" | "postgis_raster" | "postgis_sfcgal" | "postgis_tiger_geocoder" | "address_standardizer" | "address_standardizer_data_us" | "refint" | "sslinfo" | "tcn" | "timescaledb" | "vector" | "xml2";
767
+ /**
768
+ * @description Common MySQL storage engines
769
+ * @mysql only
770
+ */
771
+ type CommonMysqlEngines = "InnoDB" | "MyISAM" | "MEMORY" | "CSV" | "ARCHIVE" | "BLACKHOLE" | "NDB" | "FEDERATED";
772
+ /**
773
+ * @description Common MySQL character sets
774
+ * @mysql only
775
+ * @description utf8mb4 is recommended for new projects (full UTF-8 support including emojis)
776
+ */
777
+ type CommonMysqlCharsets = "utf8mb4" | "utf8" | "latin1" | "ascii" | "binary" | "utf16" | "utf32" | "ucs2";
778
+ /**
779
+ * @description Common MySQL collations for utf8mb4 charset
780
+ * @mysql only
781
+ * @description utf8mb4_unicode_ci is recommended for most use cases
782
+ */
783
+ type CommonMysqlUtf8mb4Collations = "utf8mb4_unicode_ci" | "utf8mb4_general_ci" | "utf8mb4_bin" | "utf8mb4_0900_ai_ci" | "utf8mb4_0900_as_ci";
784
+ /**
785
+ * @description Common MySQL collations for utf8 (legacy) charset
786
+ * @mysql only
787
+ * @description Note: utf8 is deprecated, use utf8mb4 instead
788
+ */
789
+ type CommonMysqlUtf8Collations = "utf8_unicode_ci" | "utf8_general_ci" | "utf8_bin";
790
+ /**
791
+ * @description Common MySQL collations for latin1 charset
792
+ * @mysql only
793
+ * @description latin1_swedish_ci is the default for latin1
794
+ */
795
+ type CommonMysqlLatin1Collations = "latin1_swedish_ci" | "latin1_general_ci" | "latin1_general_cs" | "latin1_bin";
796
+ /**
797
+ * @description Common MySQL collations for ascii charset
798
+ * @mysql only
799
+ */
800
+ type CommonMysqlAsciiCollations = "ascii_general_ci" | "ascii_bin";
801
+ /**
802
+ * @description All common MySQL collations (all charsets)
803
+ * @mysql only
804
+ */
805
+ type CommonMysqlCollations = CommonMysqlUtf8mb4Collations | CommonMysqlUtf8Collations | CommonMysqlLatin1Collations | CommonMysqlAsciiCollations;
806
+ /**
807
+ * @description MySQL-specific table options
808
+ * @mysql only
809
+ */
810
+ type MysqlTableOptions = {
811
+ engine?: CommonMysqlEngines | (string & {});
812
+ charset?: CommonMysqlCharsets | (string & {});
813
+ collate?: CommonMysqlCollations | (string & {});
814
+ };
815
+ /**
816
+ * @description Additional MySQL/MariaDB table options beyond engine/charset/collate
817
+ * @mysql only
818
+ */
819
+ type MysqlAdvancedTableOptions = {
820
+ rowFormat?: "DEFAULT" | "DYNAMIC" | "COMPRESSED" | "REDUNDANT" | "COMPACT" | "FIXED";
821
+ autoIncrement?: number;
822
+ dataDirectory?: string;
823
+ indexDirectory?: string;
824
+ maxRows?: number;
825
+ minRows?: number;
826
+ checksum?: boolean;
827
+ encrypted?: boolean;
828
+ comment?: string;
829
+ };
830
+ /**
831
+ * @description PostgreSQL-specific table options
832
+ * @postgres only
833
+ */
834
+ type PostgresTableOptions = {
835
+ tablespace?: string;
836
+ unlogged?: boolean;
837
+ temporary?: boolean;
838
+ with?: Record<string, string | number | boolean>;
839
+ };
840
+ /**
841
+ * @description SQLite-specific table options
842
+ * @sqlite only
843
+ */
844
+ type SqliteTableOptions = {
845
+ strict?: boolean;
846
+ withoutRowId?: boolean;
847
+ temporary?: boolean;
848
+ };
849
+ /**
850
+ * @description MSSQL-specific table options
851
+ * @mssql only
852
+ */
853
+ type MssqlTableOptions = {
854
+ onFilegroup?: string;
855
+ textImageOn?: string;
856
+ dataCompression?: "NONE" | "ROW" | "PAGE" | "COLUMNSTORE" | "COLUMNSTORE_ARCHIVE";
857
+ };
858
+ /**
859
+ * @description OracleDB-specific table options
860
+ * @oracledb only
861
+ */
862
+ type OracledbTableOptions = {
863
+ tablespace?: string;
864
+ compress?: boolean;
865
+ storage?: {
866
+ initial?: string;
867
+ next?: string;
868
+ minextents?: number;
869
+ maxextents?: string;
870
+ pctincrease?: number;
871
+ pctfree?: number;
872
+ pctused?: number;
873
+ };
874
+ logging?: boolean;
875
+ cache?: boolean;
876
+ inMemory?: boolean;
877
+ compressFor?: "QUERY LOW" | "QUERY HIGH" | "ARCHIVE LOW" | "ARCHIVE HIGH";
878
+ };
879
+ /**
880
+ * @description Union type for all database-specific table options
881
+ */
882
+ type DatabaseTableOptions = MysqlTableOptions | PostgresTableOptions | SqliteTableOptions | MssqlTableOptions | OracledbTableOptions | MysqlAdvancedTableOptions;
767
883
 
768
884
  type OpenApiModelType = {
769
885
  type: "object";
@@ -1401,6 +1517,7 @@ declare class ColumnTypeNode extends QueryNode {
1401
1517
  enumValues?: readonly string[];
1402
1518
  autoIncrement?: boolean;
1403
1519
  withTimezone?: boolean;
1520
+ collate?: string;
1404
1521
  chainsWith: string;
1405
1522
  canKeywordBeSeenMultipleTimes: boolean;
1406
1523
  folder: string;
@@ -1413,6 +1530,7 @@ declare class ColumnTypeNode extends QueryNode {
1413
1530
  enumValues?: readonly string[];
1414
1531
  withTimezone?: boolean;
1415
1532
  autoIncrement?: boolean;
1533
+ collate?: string;
1416
1534
  isRawValue?: boolean;
1417
1535
  });
1418
1536
  }
@@ -1458,12 +1576,29 @@ declare class ConstraintBuilder extends BaseBuilder {
1458
1576
  * @param options is the options for the unique constraint
1459
1577
  */
1460
1578
  unique(options?: CommonConstraintOptions): this;
1579
+ /**
1580
+ * @description Adds a CHECK constraint to the column
1581
+ * @param expression SQL expression for the check constraint (e.g., "age >= 18", "price > 0")
1582
+ * @param options Optional constraint name
1583
+ * @example
1584
+ * ```ts
1585
+ * table.integer("age").check("age >= 18");
1586
+ * table.decimal("price").check("price > 0", { constraintName: "positive_price" });
1587
+ * ```
1588
+ */
1589
+ check(expression: string, options?: CommonConstraintOptions): this;
1461
1590
  /**
1462
1591
  * @description Sets the column to be after another column
1463
1592
  * @param columnName is the name of the column to be after
1464
1593
  * @mysql only
1465
1594
  */
1466
1595
  after(columnName: string): this;
1596
+ /**
1597
+ * @description Sets the COLLATE for the column
1598
+ * @mysql only
1599
+ */
1600
+ collate(collation: CommonMysqlCollations): this;
1601
+ collate(collation: string): this;
1467
1602
  private handleSqliteAutoIncrement;
1468
1603
  }
1469
1604
 
@@ -1472,7 +1607,10 @@ declare class CreateTableBuilder extends BaseBuilder {
1472
1607
  private namedConstraints;
1473
1608
  private context;
1474
1609
  private sqlType;
1610
+ private _mysqlOptions?;
1475
1611
  constructor(sqlType: SqlDataSourceType, nodes: QueryNode[], tableName?: string, context?: "alter_table" | "create_table");
1612
+ mysqlOptions(options: MysqlTableOptions): this;
1613
+ getMysqlOptions(): MysqlTableOptions | undefined;
1476
1614
  private build;
1477
1615
  /**
1478
1616
  * @description Adds a raw statement to define a default value as is
@@ -1794,7 +1932,7 @@ declare class CreateTableBuilder extends BaseBuilder {
1794
1932
  getNamedConstraints(): QueryNode[];
1795
1933
  }
1796
1934
 
1797
- type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default";
1935
+ type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default" | "check";
1798
1936
  declare class ConstraintNode extends QueryNode {
1799
1937
  constraintType: ConstraintType;
1800
1938
  columns?: (string | (() => string))[];
@@ -1957,6 +2095,74 @@ declare class AlterTableBuilder extends BaseBuilder {
1957
2095
  * @mssql Foreign keys referencing this primary key must be dropped first
1958
2096
  */
1959
2097
  dropPrimaryKey(table?: string): void;
2098
+ /**
2099
+ * @description Sets table options for ALTER TABLE
2100
+ * @mysql Supports: engine, charset, collate, rowFormat, autoIncrement, dataDirectory, etc.
2101
+ * @postgres Supports: tablespace, with storage parameters
2102
+ * @sqlite Not supported for ALTER TABLE table options (most table options are CREATE TABLE only)
2103
+ * @mssql Supports: onFilegroup, dataCompression
2104
+ * @oracledb Supports: tablespace, compress, storage parameters
2105
+ */
2106
+ setTableOptions(options: MysqlTableOptions & MysqlAdvancedTableOptions): this;
2107
+ setTableOptions(options: PostgresTableOptions): this;
2108
+ setTableOptions(options: SqliteTableOptions): this;
2109
+ setTableOptions(options: MssqlTableOptions): this;
2110
+ setTableOptions(options: OracledbTableOptions): this;
2111
+ setTableOptions(options: {
2112
+ engine?: CommonMysqlEngines | string;
2113
+ charset?: CommonMysqlCharsets | string;
2114
+ collate?: CommonMysqlCollations | string;
2115
+ rowFormat?: "DEFAULT" | "DYNAMIC" | "COMPRESSED" | "REDUNDANT" | "COMPACT" | "FIXED";
2116
+ autoIncrement?: number;
2117
+ dataDirectory?: string;
2118
+ indexDirectory?: string;
2119
+ maxRows?: number;
2120
+ minRows?: number;
2121
+ checksum?: boolean;
2122
+ encrypted?: boolean;
2123
+ comment?: string;
2124
+ }): this;
2125
+ setTableOptions(options: {
2126
+ engine?: CommonMysqlEngines | string;
2127
+ charset?: CommonMysqlCharsets | string;
2128
+ collate?: CommonMysqlCollations | string;
2129
+ }): this;
2130
+ setTableOptions(options: {
2131
+ tablespace?: string;
2132
+ unlogged?: boolean;
2133
+ temporary?: boolean;
2134
+ with?: Record<string, string | number | boolean>;
2135
+ }): this;
2136
+ setTableOptions(options: {
2137
+ strict?: boolean;
2138
+ withoutRowId?: boolean;
2139
+ temporary?: boolean;
2140
+ }): this;
2141
+ setTableOptions(options: {
2142
+ onFilegroup?: string;
2143
+ textImageOn?: string;
2144
+ dataCompression?: "NONE" | "ROW" | "PAGE" | "COLUMNSTORE" | "COLUMNSTORE_ARCHIVE";
2145
+ }): this;
2146
+ setTableOptions(options: {
2147
+ tablespace?: string;
2148
+ compress?: boolean;
2149
+ storage?: {
2150
+ initial?: string;
2151
+ next?: string;
2152
+ minextents?: number;
2153
+ maxextents?: string;
2154
+ pctincrease?: number;
2155
+ pctfree?: number;
2156
+ pctused?: number;
2157
+ };
2158
+ logging?: boolean;
2159
+ cache?: boolean;
2160
+ inMemory?: boolean;
2161
+ compressFor?: "QUERY LOW" | "QUERY HIGH" | "ARCHIVE LOW" | "ARCHIVE HIGH";
2162
+ }): this;
2163
+ setTableOptions(options: {
2164
+ ifNotExists?: boolean;
2165
+ } & DatabaseTableOptions): this;
1960
2166
  }
1961
2167
 
1962
2168
  /**
@@ -2011,7 +2217,7 @@ declare class SchemaBuilder implements PromiseLike<void> {
2011
2217
  */
2012
2218
  createTable(table: string, cb: (table: CreateTableBuilder) => void, options?: {
2013
2219
  ifNotExists?: boolean;
2014
- }): this;
2220
+ } & DatabaseTableOptions): this;
2015
2221
  /**
2016
2222
  * @description Alter table constructor
2017
2223
  */
@@ -7470,7 +7676,7 @@ declare class Schema {
7470
7676
  */
7471
7677
  createTable(table: string, cb: (table: CreateTableBuilder) => void, options?: {
7472
7678
  ifNotExists?: boolean;
7473
- }): void;
7679
+ } & DatabaseTableOptions): void;
7474
7680
  /**
7475
7681
  * @description Alter table constructor
7476
7682
  * @mssql Limited support - cannot modify columns with constraints; see AlterTableBuilder methods for details
@@ -7528,6 +7734,28 @@ declare class Schema {
7528
7734
  * @description Drops a constraint from a table
7529
7735
  */
7530
7736
  dropConstraint(table: string, constraintName: string): void;
7737
+ /**
7738
+ * @description Adds a CHECK constraint to a table
7739
+ * @param table The table name
7740
+ * @param expression The SQL expression for the check constraint (e.g., "age >= 18", "price > 0")
7741
+ * @param options Optional constraint name and other options
7742
+ * @example
7743
+ * ```ts
7744
+ * schema.addCheck("users", "age >= 18", { constraintName: "users_age_check" });
7745
+ * schema.addCheck("products", "price > 0 AND stock >= 0");
7746
+ * ```
7747
+ */
7748
+ addCheck(table: string, expression: string, options?: CommonConstraintOptions): void;
7749
+ /**
7750
+ * @description Drops a CHECK constraint from a table
7751
+ * @param table The table name
7752
+ * @param constraintName The name of the check constraint to drop
7753
+ * @example
7754
+ * ```ts
7755
+ * schema.dropCheck("users", "users_age_check");
7756
+ * ```
7757
+ */
7758
+ dropCheck(table: string, constraintName: string): void;
7531
7759
  /**
7532
7760
  * @description Create database extension, only supported for postgres
7533
7761
  * @postgres Supports extensions like PostGIS, uuid-ossp, hstore, etc.
package/lib/index.d.ts CHANGED
@@ -764,6 +764,122 @@ type ForeignKeyOptions = CommonConstraintOptions & {
764
764
  };
765
765
  type CreateTableContext = "alter_table" | "create_table";
766
766
  type CommonPostgresExtensions = "postgis" | "uuid-ossp" | "hstore" | "pg_trgm" | "btree_gin" | "btree_gist" | "citext" | "pgcrypto" | "tablefunc" | "unaccent" | "pg_stat_statements" | "ltree" | "cube" | "earthdistance" | "fuzzystrmatch" | "intarray" | "isn" | "lo" | "pg_buffercache" | "pgrowlocks" | "pgstattuple" | "pg_freespacemap" | "postgres_fdw" | "seg" | "tsm_system_rows" | "tsm_system_time" | "plpgsql" | "plperl" | "plpython3u" | "pltcl" | "adminpack" | "amcheck" | "autoinc" | "bloom" | "dict_int" | "dict_xsyn" | "file_fdw" | "insert_username" | "intagg" | "moddatetime" | "old_snapshot" | "pageinspect" | "pg_prewarm" | "pg_surgery" | "pg_visibility" | "pgaudit" | "pglogical" | "pgrouting" | "postgis_topology" | "postgis_raster" | "postgis_sfcgal" | "postgis_tiger_geocoder" | "address_standardizer" | "address_standardizer_data_us" | "refint" | "sslinfo" | "tcn" | "timescaledb" | "vector" | "xml2";
767
+ /**
768
+ * @description Common MySQL storage engines
769
+ * @mysql only
770
+ */
771
+ type CommonMysqlEngines = "InnoDB" | "MyISAM" | "MEMORY" | "CSV" | "ARCHIVE" | "BLACKHOLE" | "NDB" | "FEDERATED";
772
+ /**
773
+ * @description Common MySQL character sets
774
+ * @mysql only
775
+ * @description utf8mb4 is recommended for new projects (full UTF-8 support including emojis)
776
+ */
777
+ type CommonMysqlCharsets = "utf8mb4" | "utf8" | "latin1" | "ascii" | "binary" | "utf16" | "utf32" | "ucs2";
778
+ /**
779
+ * @description Common MySQL collations for utf8mb4 charset
780
+ * @mysql only
781
+ * @description utf8mb4_unicode_ci is recommended for most use cases
782
+ */
783
+ type CommonMysqlUtf8mb4Collations = "utf8mb4_unicode_ci" | "utf8mb4_general_ci" | "utf8mb4_bin" | "utf8mb4_0900_ai_ci" | "utf8mb4_0900_as_ci";
784
+ /**
785
+ * @description Common MySQL collations for utf8 (legacy) charset
786
+ * @mysql only
787
+ * @description Note: utf8 is deprecated, use utf8mb4 instead
788
+ */
789
+ type CommonMysqlUtf8Collations = "utf8_unicode_ci" | "utf8_general_ci" | "utf8_bin";
790
+ /**
791
+ * @description Common MySQL collations for latin1 charset
792
+ * @mysql only
793
+ * @description latin1_swedish_ci is the default for latin1
794
+ */
795
+ type CommonMysqlLatin1Collations = "latin1_swedish_ci" | "latin1_general_ci" | "latin1_general_cs" | "latin1_bin";
796
+ /**
797
+ * @description Common MySQL collations for ascii charset
798
+ * @mysql only
799
+ */
800
+ type CommonMysqlAsciiCollations = "ascii_general_ci" | "ascii_bin";
801
+ /**
802
+ * @description All common MySQL collations (all charsets)
803
+ * @mysql only
804
+ */
805
+ type CommonMysqlCollations = CommonMysqlUtf8mb4Collations | CommonMysqlUtf8Collations | CommonMysqlLatin1Collations | CommonMysqlAsciiCollations;
806
+ /**
807
+ * @description MySQL-specific table options
808
+ * @mysql only
809
+ */
810
+ type MysqlTableOptions = {
811
+ engine?: CommonMysqlEngines | (string & {});
812
+ charset?: CommonMysqlCharsets | (string & {});
813
+ collate?: CommonMysqlCollations | (string & {});
814
+ };
815
+ /**
816
+ * @description Additional MySQL/MariaDB table options beyond engine/charset/collate
817
+ * @mysql only
818
+ */
819
+ type MysqlAdvancedTableOptions = {
820
+ rowFormat?: "DEFAULT" | "DYNAMIC" | "COMPRESSED" | "REDUNDANT" | "COMPACT" | "FIXED";
821
+ autoIncrement?: number;
822
+ dataDirectory?: string;
823
+ indexDirectory?: string;
824
+ maxRows?: number;
825
+ minRows?: number;
826
+ checksum?: boolean;
827
+ encrypted?: boolean;
828
+ comment?: string;
829
+ };
830
+ /**
831
+ * @description PostgreSQL-specific table options
832
+ * @postgres only
833
+ */
834
+ type PostgresTableOptions = {
835
+ tablespace?: string;
836
+ unlogged?: boolean;
837
+ temporary?: boolean;
838
+ with?: Record<string, string | number | boolean>;
839
+ };
840
+ /**
841
+ * @description SQLite-specific table options
842
+ * @sqlite only
843
+ */
844
+ type SqliteTableOptions = {
845
+ strict?: boolean;
846
+ withoutRowId?: boolean;
847
+ temporary?: boolean;
848
+ };
849
+ /**
850
+ * @description MSSQL-specific table options
851
+ * @mssql only
852
+ */
853
+ type MssqlTableOptions = {
854
+ onFilegroup?: string;
855
+ textImageOn?: string;
856
+ dataCompression?: "NONE" | "ROW" | "PAGE" | "COLUMNSTORE" | "COLUMNSTORE_ARCHIVE";
857
+ };
858
+ /**
859
+ * @description OracleDB-specific table options
860
+ * @oracledb only
861
+ */
862
+ type OracledbTableOptions = {
863
+ tablespace?: string;
864
+ compress?: boolean;
865
+ storage?: {
866
+ initial?: string;
867
+ next?: string;
868
+ minextents?: number;
869
+ maxextents?: string;
870
+ pctincrease?: number;
871
+ pctfree?: number;
872
+ pctused?: number;
873
+ };
874
+ logging?: boolean;
875
+ cache?: boolean;
876
+ inMemory?: boolean;
877
+ compressFor?: "QUERY LOW" | "QUERY HIGH" | "ARCHIVE LOW" | "ARCHIVE HIGH";
878
+ };
879
+ /**
880
+ * @description Union type for all database-specific table options
881
+ */
882
+ type DatabaseTableOptions = MysqlTableOptions | PostgresTableOptions | SqliteTableOptions | MssqlTableOptions | OracledbTableOptions | MysqlAdvancedTableOptions;
767
883
 
768
884
  type OpenApiModelType = {
769
885
  type: "object";
@@ -1401,6 +1517,7 @@ declare class ColumnTypeNode extends QueryNode {
1401
1517
  enumValues?: readonly string[];
1402
1518
  autoIncrement?: boolean;
1403
1519
  withTimezone?: boolean;
1520
+ collate?: string;
1404
1521
  chainsWith: string;
1405
1522
  canKeywordBeSeenMultipleTimes: boolean;
1406
1523
  folder: string;
@@ -1413,6 +1530,7 @@ declare class ColumnTypeNode extends QueryNode {
1413
1530
  enumValues?: readonly string[];
1414
1531
  withTimezone?: boolean;
1415
1532
  autoIncrement?: boolean;
1533
+ collate?: string;
1416
1534
  isRawValue?: boolean;
1417
1535
  });
1418
1536
  }
@@ -1458,12 +1576,29 @@ declare class ConstraintBuilder extends BaseBuilder {
1458
1576
  * @param options is the options for the unique constraint
1459
1577
  */
1460
1578
  unique(options?: CommonConstraintOptions): this;
1579
+ /**
1580
+ * @description Adds a CHECK constraint to the column
1581
+ * @param expression SQL expression for the check constraint (e.g., "age >= 18", "price > 0")
1582
+ * @param options Optional constraint name
1583
+ * @example
1584
+ * ```ts
1585
+ * table.integer("age").check("age >= 18");
1586
+ * table.decimal("price").check("price > 0", { constraintName: "positive_price" });
1587
+ * ```
1588
+ */
1589
+ check(expression: string, options?: CommonConstraintOptions): this;
1461
1590
  /**
1462
1591
  * @description Sets the column to be after another column
1463
1592
  * @param columnName is the name of the column to be after
1464
1593
  * @mysql only
1465
1594
  */
1466
1595
  after(columnName: string): this;
1596
+ /**
1597
+ * @description Sets the COLLATE for the column
1598
+ * @mysql only
1599
+ */
1600
+ collate(collation: CommonMysqlCollations): this;
1601
+ collate(collation: string): this;
1467
1602
  private handleSqliteAutoIncrement;
1468
1603
  }
1469
1604
 
@@ -1472,7 +1607,10 @@ declare class CreateTableBuilder extends BaseBuilder {
1472
1607
  private namedConstraints;
1473
1608
  private context;
1474
1609
  private sqlType;
1610
+ private _mysqlOptions?;
1475
1611
  constructor(sqlType: SqlDataSourceType, nodes: QueryNode[], tableName?: string, context?: "alter_table" | "create_table");
1612
+ mysqlOptions(options: MysqlTableOptions): this;
1613
+ getMysqlOptions(): MysqlTableOptions | undefined;
1476
1614
  private build;
1477
1615
  /**
1478
1616
  * @description Adds a raw statement to define a default value as is
@@ -1794,7 +1932,7 @@ declare class CreateTableBuilder extends BaseBuilder {
1794
1932
  getNamedConstraints(): QueryNode[];
1795
1933
  }
1796
1934
 
1797
- type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default";
1935
+ type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default" | "check";
1798
1936
  declare class ConstraintNode extends QueryNode {
1799
1937
  constraintType: ConstraintType;
1800
1938
  columns?: (string | (() => string))[];
@@ -1957,6 +2095,74 @@ declare class AlterTableBuilder extends BaseBuilder {
1957
2095
  * @mssql Foreign keys referencing this primary key must be dropped first
1958
2096
  */
1959
2097
  dropPrimaryKey(table?: string): void;
2098
+ /**
2099
+ * @description Sets table options for ALTER TABLE
2100
+ * @mysql Supports: engine, charset, collate, rowFormat, autoIncrement, dataDirectory, etc.
2101
+ * @postgres Supports: tablespace, with storage parameters
2102
+ * @sqlite Not supported for ALTER TABLE table options (most table options are CREATE TABLE only)
2103
+ * @mssql Supports: onFilegroup, dataCompression
2104
+ * @oracledb Supports: tablespace, compress, storage parameters
2105
+ */
2106
+ setTableOptions(options: MysqlTableOptions & MysqlAdvancedTableOptions): this;
2107
+ setTableOptions(options: PostgresTableOptions): this;
2108
+ setTableOptions(options: SqliteTableOptions): this;
2109
+ setTableOptions(options: MssqlTableOptions): this;
2110
+ setTableOptions(options: OracledbTableOptions): this;
2111
+ setTableOptions(options: {
2112
+ engine?: CommonMysqlEngines | string;
2113
+ charset?: CommonMysqlCharsets | string;
2114
+ collate?: CommonMysqlCollations | string;
2115
+ rowFormat?: "DEFAULT" | "DYNAMIC" | "COMPRESSED" | "REDUNDANT" | "COMPACT" | "FIXED";
2116
+ autoIncrement?: number;
2117
+ dataDirectory?: string;
2118
+ indexDirectory?: string;
2119
+ maxRows?: number;
2120
+ minRows?: number;
2121
+ checksum?: boolean;
2122
+ encrypted?: boolean;
2123
+ comment?: string;
2124
+ }): this;
2125
+ setTableOptions(options: {
2126
+ engine?: CommonMysqlEngines | string;
2127
+ charset?: CommonMysqlCharsets | string;
2128
+ collate?: CommonMysqlCollations | string;
2129
+ }): this;
2130
+ setTableOptions(options: {
2131
+ tablespace?: string;
2132
+ unlogged?: boolean;
2133
+ temporary?: boolean;
2134
+ with?: Record<string, string | number | boolean>;
2135
+ }): this;
2136
+ setTableOptions(options: {
2137
+ strict?: boolean;
2138
+ withoutRowId?: boolean;
2139
+ temporary?: boolean;
2140
+ }): this;
2141
+ setTableOptions(options: {
2142
+ onFilegroup?: string;
2143
+ textImageOn?: string;
2144
+ dataCompression?: "NONE" | "ROW" | "PAGE" | "COLUMNSTORE" | "COLUMNSTORE_ARCHIVE";
2145
+ }): this;
2146
+ setTableOptions(options: {
2147
+ tablespace?: string;
2148
+ compress?: boolean;
2149
+ storage?: {
2150
+ initial?: string;
2151
+ next?: string;
2152
+ minextents?: number;
2153
+ maxextents?: string;
2154
+ pctincrease?: number;
2155
+ pctfree?: number;
2156
+ pctused?: number;
2157
+ };
2158
+ logging?: boolean;
2159
+ cache?: boolean;
2160
+ inMemory?: boolean;
2161
+ compressFor?: "QUERY LOW" | "QUERY HIGH" | "ARCHIVE LOW" | "ARCHIVE HIGH";
2162
+ }): this;
2163
+ setTableOptions(options: {
2164
+ ifNotExists?: boolean;
2165
+ } & DatabaseTableOptions): this;
1960
2166
  }
1961
2167
 
1962
2168
  /**
@@ -2011,7 +2217,7 @@ declare class SchemaBuilder implements PromiseLike<void> {
2011
2217
  */
2012
2218
  createTable(table: string, cb: (table: CreateTableBuilder) => void, options?: {
2013
2219
  ifNotExists?: boolean;
2014
- }): this;
2220
+ } & DatabaseTableOptions): this;
2015
2221
  /**
2016
2222
  * @description Alter table constructor
2017
2223
  */
@@ -7470,7 +7676,7 @@ declare class Schema {
7470
7676
  */
7471
7677
  createTable(table: string, cb: (table: CreateTableBuilder) => void, options?: {
7472
7678
  ifNotExists?: boolean;
7473
- }): void;
7679
+ } & DatabaseTableOptions): void;
7474
7680
  /**
7475
7681
  * @description Alter table constructor
7476
7682
  * @mssql Limited support - cannot modify columns with constraints; see AlterTableBuilder methods for details
@@ -7528,6 +7734,28 @@ declare class Schema {
7528
7734
  * @description Drops a constraint from a table
7529
7735
  */
7530
7736
  dropConstraint(table: string, constraintName: string): void;
7737
+ /**
7738
+ * @description Adds a CHECK constraint to a table
7739
+ * @param table The table name
7740
+ * @param expression The SQL expression for the check constraint (e.g., "age >= 18", "price > 0")
7741
+ * @param options Optional constraint name and other options
7742
+ * @example
7743
+ * ```ts
7744
+ * schema.addCheck("users", "age >= 18", { constraintName: "users_age_check" });
7745
+ * schema.addCheck("products", "price > 0 AND stock >= 0");
7746
+ * ```
7747
+ */
7748
+ addCheck(table: string, expression: string, options?: CommonConstraintOptions): void;
7749
+ /**
7750
+ * @description Drops a CHECK constraint from a table
7751
+ * @param table The table name
7752
+ * @param constraintName The name of the check constraint to drop
7753
+ * @example
7754
+ * ```ts
7755
+ * schema.dropCheck("users", "users_age_check");
7756
+ * ```
7757
+ */
7758
+ dropCheck(table: string, constraintName: string): void;
7531
7759
  /**
7532
7760
  * @description Create database extension, only supported for postgres
7533
7761
  * @postgres Supports extensions like PostGIS, uuid-ossp, hstore, etc.