hysteria-orm 10.5.7 → 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
@@ -1576,6 +1576,17 @@ declare class ConstraintBuilder extends BaseBuilder {
1576
1576
  * @param options is the options for the unique constraint
1577
1577
  */
1578
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;
1579
1590
  /**
1580
1591
  * @description Sets the column to be after another column
1581
1592
  * @param columnName is the name of the column to be after
@@ -1921,7 +1932,7 @@ declare class CreateTableBuilder extends BaseBuilder {
1921
1932
  getNamedConstraints(): QueryNode[];
1922
1933
  }
1923
1934
 
1924
- type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default";
1935
+ type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default" | "check";
1925
1936
  declare class ConstraintNode extends QueryNode {
1926
1937
  constraintType: ConstraintType;
1927
1938
  columns?: (string | (() => string))[];
@@ -7723,6 +7734,28 @@ declare class Schema {
7723
7734
  * @description Drops a constraint from a table
7724
7735
  */
7725
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;
7726
7759
  /**
7727
7760
  * @description Create database extension, only supported for postgres
7728
7761
  * @postgres Supports extensions like PostGIS, uuid-ossp, hstore, etc.
package/lib/index.d.ts CHANGED
@@ -1576,6 +1576,17 @@ declare class ConstraintBuilder extends BaseBuilder {
1576
1576
  * @param options is the options for the unique constraint
1577
1577
  */
1578
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;
1579
1590
  /**
1580
1591
  * @description Sets the column to be after another column
1581
1592
  * @param columnName is the name of the column to be after
@@ -1921,7 +1932,7 @@ declare class CreateTableBuilder extends BaseBuilder {
1921
1932
  getNamedConstraints(): QueryNode[];
1922
1933
  }
1923
1934
 
1924
- type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default";
1935
+ type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default" | "check";
1925
1936
  declare class ConstraintNode extends QueryNode {
1926
1937
  constraintType: ConstraintType;
1927
1938
  columns?: (string | (() => string))[];
@@ -7723,6 +7734,28 @@ declare class Schema {
7723
7734
  * @description Drops a constraint from a table
7724
7735
  */
7725
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;
7726
7759
  /**
7727
7760
  * @description Create database extension, only supported for postgres
7728
7761
  * @postgres Supports extensions like PostGIS, uuid-ossp, hstore, etc.