Skip to content

Commit

Permalink
fix: add notNull constraint with defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Aericio committed May 29, 2024
1 parent 8dcb2d7 commit 0abe5b5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 29 deletions.
14 changes: 7 additions & 7 deletions dist/lib/database.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default function initializeDatabase({ connectionUri, }: {
columnType: "PgArray";
data: string[];
driverParam: string | string[];
notNull: false;
notNull: true;
hasDefault: true;
enumValues: [string, ...string[]];
baseColumn: import("drizzle-orm").Column<{
Expand All @@ -185,7 +185,7 @@ export default function initializeDatabase({ connectionUri, }: {
columnType: "PgTimestamp";
data: Date;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: undefined;
baseColumn: never;
Expand All @@ -197,7 +197,7 @@ export default function initializeDatabase({ connectionUri, }: {
columnType: "PgTimestamp";
data: Date;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: undefined;
baseColumn: never;
Expand Down Expand Up @@ -252,7 +252,7 @@ export default function initializeDatabase({ connectionUri, }: {
columnType: "PgText";
data: string;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: [string, ...string[]];
baseColumn: never;
Expand All @@ -264,7 +264,7 @@ export default function initializeDatabase({ connectionUri, }: {
columnType: "PgText";
data: string;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: [string, ...string[]];
baseColumn: never;
Expand All @@ -276,7 +276,7 @@ export default function initializeDatabase({ connectionUri, }: {
columnType: "PgTimestamp";
data: Date;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: undefined;
baseColumn: never;
Expand All @@ -288,7 +288,7 @@ export default function initializeDatabase({ connectionUri, }: {
columnType: "PgTimestamp";
data: Date;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: undefined;
baseColumn: never;
Expand Down
14 changes: 7 additions & 7 deletions dist/lib/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export declare const players: import("drizzle-orm/pg-core").PgTableWithColumns<{
columnType: "PgText";
data: string;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: [string, ...string[]];
baseColumn: never;
Expand All @@ -57,7 +57,7 @@ export declare const players: import("drizzle-orm/pg-core").PgTableWithColumns<{
columnType: "PgText";
data: string;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: [string, ...string[]];
baseColumn: never;
Expand All @@ -69,7 +69,7 @@ export declare const players: import("drizzle-orm/pg-core").PgTableWithColumns<{
columnType: "PgTimestamp";
data: Date;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: undefined;
baseColumn: never;
Expand All @@ -81,7 +81,7 @@ export declare const players: import("drizzle-orm/pg-core").PgTableWithColumns<{
columnType: "PgTimestamp";
data: Date;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: undefined;
baseColumn: never;
Expand Down Expand Up @@ -244,7 +244,7 @@ export declare const cosmetics: import("drizzle-orm/pg-core").PgTableWithColumns
columnType: "PgArray";
data: string[];
driverParam: string | string[];
notNull: false;
notNull: true;
hasDefault: true;
enumValues: [string, ...string[]];
baseColumn: import("drizzle-orm").Column<{
Expand All @@ -267,7 +267,7 @@ export declare const cosmetics: import("drizzle-orm/pg-core").PgTableWithColumns
columnType: "PgTimestamp";
data: Date;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: undefined;
baseColumn: never;
Expand All @@ -279,7 +279,7 @@ export declare const cosmetics: import("drizzle-orm/pg-core").PgTableWithColumns
columnType: "PgTimestamp";
data: Date;
driverParam: string;
notNull: false;
notNull: true;
hasDefault: true;
enumValues: undefined;
baseColumn: never;
Expand Down
17 changes: 10 additions & 7 deletions dist/lib/schema.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/lib/schema.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions src/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export const players = pgTable("players", {
uuid: text("uuid").primaryKey().notNull(),
username: text("username").notNull(),
rank: text("rank").notNull(),
equipped_avatar_id: text("equipped_avatar_id").default("default"),
equipped_avatar_name: text("equipped_avatar_name").default("Default"),
created_at: timestamp("created_at").defaultNow(),
updated_at: timestamp("updated_at").defaultNow(),
equipped_avatar_id: text("equipped_avatar_id").default("default").notNull(),
equipped_avatar_name: text("equipped_avatar_name")
.default("Default")
.notNull(),
created_at: timestamp("created_at").defaultNow().notNull(),
updated_at: timestamp("updated_at").defaultNow().notNull(),
});

export const cosmetics = pgTable("cosmetics", {
Expand All @@ -33,7 +35,8 @@ export const cosmetics = pgTable("cosmetics", {
price: integer("price").notNull(),
manual_tags: text("manual_tags")
.array()
.default(sql`ARRAY[]::text[]`),
row_created: timestamp("row_created").defaultNow(),
row_updated: timestamp("row_updated").defaultNow(),
.default(sql`ARRAY[]::text[]`)
.notNull(),
row_created: timestamp("row_created").defaultNow().notNull(),
row_updated: timestamp("row_updated").defaultNow().notNull(),
});

0 comments on commit 0abe5b5

Please sign in to comment.