focused_morning
focused_morning
DTDrizzle Team
Created by focused_morning on 8/9/2023 in #help
Top Level await issue with latest [email protected], mysql2, planetscale
Drove us crazy too.
8 replies
DTDrizzle Team
Created by ippo on 9/15/2023 in #help
TRIGGERS in Drizzle
What if you are using planetscale and are letting planetscale handle migrations?
13 replies
DTDrizzle Team
Created by focused_morning on 10/31/2023 in #help
How do I write a trigger??
using mysql and planetscale
4 replies
DTDrizzle Team
Created by focused_morning on 10/31/2023 in #help
How can I accomplish this in a schema?
I keep getting this error: code: 'ER_PARSE_ERROR', errno: 1064, sql: "ALTER TABLE ItemMintPermission ADD activeItemId AS (CASE WHEN status='ACTIVE' THEN itemId ELSE NULL END);", but the sql looks right to me
10 replies
DTDrizzle Team
Created by focused_morning on 10/31/2023 in #help
How can I accomplish this in a schema?
so I can exclude that keyword, im not 100% sure on that.
10 replies
DTDrizzle Team
Created by focused_morning on 10/31/2023 in #help
How can I accomplish this in a schema?
seems to not like virtual keyword
10 replies
DTDrizzle Team
Created by focused_morning on 10/31/2023 in #help
How can I accomplish this in a schema?
its mysql btw
10 replies
DTDrizzle Team
Created by focused_morning on 8/29/2023 in #help
Help, issue that will drop our user table
migration:
CREATE TABLE `User` (
`id` varchar(191) NOT NULL,
`username` varchar(191),
`profileImageUrl` varchar(191),
`email` varchar(191),
`bio` text,
`headline` text,
`website` varchar(191),
`twitter` varchar(191),
`instagram` varchar(191),
`opensea` varchar(191),
`membershipTier` enum('COMMON','RARE','EPIC','LEGENDARY','PN'),
`role` enum('ADMIN','CREATOR','USER') NOT NULL DEFAULT 'USER',
`createdAt` datetime(3) NOT NULL DEFAULT (CURRENT_TIMESTAMP(3)),
`updatedAt` datetime(3) NOT NULL DEFAULT (CURRENT_TIMESTAMP(3)),
CONSTRAINT `User_id` PRIMARY KEY(`id`),
CONSTRAINT `User_username_key` UNIQUE(`username`)
);
CREATE TABLE `User` (
`id` varchar(191) NOT NULL,
`username` varchar(191),
`profileImageUrl` varchar(191),
`email` varchar(191),
`bio` text,
`headline` text,
`website` varchar(191),
`twitter` varchar(191),
`instagram` varchar(191),
`opensea` varchar(191),
`membershipTier` enum('COMMON','RARE','EPIC','LEGENDARY','PN'),
`role` enum('ADMIN','CREATOR','USER') NOT NULL DEFAULT 'USER',
`createdAt` datetime(3) NOT NULL DEFAULT (CURRENT_TIMESTAMP(3)),
`updatedAt` datetime(3) NOT NULL DEFAULT (CURRENT_TIMESTAMP(3)),
CONSTRAINT `User_id` PRIMARY KEY(`id`),
CONSTRAINT `User_username_key` UNIQUE(`username`)
);
pscale:
CREATE TABLE `User` (
`id` varchar(191) NOT NULL,
`username` varchar(191),
`profileImageUrl` varchar(191),
`email` varchar(191),
`bio` text,
`headline` text,
`website` varchar(191),
`twitter` varchar(191),
`instagram` varchar(191),
`opensea` varchar(191),
`role` enum('ADMIN', 'CREATOR', 'USER') NOT NULL DEFAULT 'USER',
`createdAt` datetime(3) NOT NULL DEFAULT current_timestamp(3),
`updatedAt` datetime(3) NOT NULL DEFAULT current_timestamp(3),
`membershipTier` enum('COMMON', 'RARE', 'EPIC', 'LEGENDARY', 'PN'),
PRIMARY KEY (`id`),
UNIQUE KEY `User_username_key` (`username`),
KEY `User_username_idx` (`username`)
) ENGINE InnoDB,
CHARSET utf8mb4,
COLLATE utf8mb4_0900_ai_ci;
CREATE TABLE `User` (
`id` varchar(191) NOT NULL,
`username` varchar(191),
`profileImageUrl` varchar(191),
`email` varchar(191),
`bio` text,
`headline` text,
`website` varchar(191),
`twitter` varchar(191),
`instagram` varchar(191),
`opensea` varchar(191),
`role` enum('ADMIN', 'CREATOR', 'USER') NOT NULL DEFAULT 'USER',
`createdAt` datetime(3) NOT NULL DEFAULT current_timestamp(3),
`updatedAt` datetime(3) NOT NULL DEFAULT current_timestamp(3),
`membershipTier` enum('COMMON', 'RARE', 'EPIC', 'LEGENDARY', 'PN'),
PRIMARY KEY (`id`),
UNIQUE KEY `User_username_key` (`username`),
KEY `User_username_idx` (`username`)
) ENGINE InnoDB,
CHARSET utf8mb4,
COLLATE utf8mb4_0900_ai_ci;
2 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
I appreciate the insights thank you, I'll try it out but I don't like the idea of dropping data to fix this.
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
I tried this: timestamp("createdAt").default(sqlcurrent_timestamp) earlier without success.. Oddly enough the push command is failing, but planetscale is registering some of the changes including the createdAt change, but the command is failing so the other schema changes aren't included.
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
I also tried this with no success. Not sure what i'm doing wrong, any thoughts? @angelelz timestamp("createdAt").defaultNow()
ALTER TABLE `InventoryItem` MODIFY COLUMN `createdAt` timestamp DEFAULT (now());
ALTER TABLE `InventoryItem` MODIFY COLUMN `createdAt` timestamp DEFAULT (now());
Error: target: americana-db.-.primary: vttablet: rpc error: code = InvalidArgument desc = Invalid default value for 'updatedAt' (errno 1067) (sqlstate 42000) (CallerID: planetscale-admin): Sql: "alter table InventoryItem modify column createdAt timestamp default (now())", BindVars: {REDACTED}
at PromiseConnection.query (/Users/robmartin/Projects/americana-neue/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/Users/robmartin/Projects/americana-neue/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53292:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ER_INVALID_DEFAULT',
errno: 1067,
sql: 'ALTER TABLE `InventoryItem` MODIFY COLUMN `createdAt` timestamp DEFAULT (now());',
sqlState: '42000',
sqlMessage: `target: americana-db.-.primary: vttablet: rpc error: code = InvalidArgument desc = Invalid default value for 'updatedAt' (errno 1067) (sqlstate 42000) (CallerID: planetscale-admin): Sql: "alter table InventoryItem modify column createdAt timestamp default (now())", BindVars: {REDACTED}`
Error: target: americana-db.-.primary: vttablet: rpc error: code = InvalidArgument desc = Invalid default value for 'updatedAt' (errno 1067) (sqlstate 42000) (CallerID: planetscale-admin): Sql: "alter table InventoryItem modify column createdAt timestamp default (now())", BindVars: {REDACTED}
at PromiseConnection.query (/Users/robmartin/Projects/americana-neue/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/Users/robmartin/Projects/americana-neue/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53292:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ER_INVALID_DEFAULT',
errno: 1067,
sql: 'ALTER TABLE `InventoryItem` MODIFY COLUMN `createdAt` timestamp DEFAULT (now());',
sqlState: '42000',
sqlMessage: `target: americana-db.-.primary: vttablet: rpc error: code = InvalidArgument desc = Invalid default value for 'updatedAt' (errno 1067) (sqlstate 42000) (CallerID: planetscale-admin): Sql: "alter table InventoryItem modify column createdAt timestamp default (now())", BindVars: {REDACTED}`
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
@iceage2ondvd
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
timestamp("time").default(sqlcurrent_timestamp()) doesnt work for me.
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
Updating this post, this doesn't work. Trying @iceage2ondvd 's fix next and will update.
createdAt: datetime("createdAt", { mode: "string", fsp: 3 })
.default(sql`(now(3))`)
.notNull(),
createdAt: datetime("createdAt", { mode: "string", fsp: 3 })
.default(sql`(now(3))`)
.notNull(),
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
no worries, I just want your question answered.
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
@justhugo I would ask in a separate thread so this one stays on topic.
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
ALTER TABLE `InventoryItem` MODIFY COLUMN `createdAt` datetime(3) NOT NULL DEFAULT (CURRENT_TIMESTAMP(3));--> statement-breakpoint
ALTER TABLE `InventoryItem` MODIFY COLUMN `updatedAt` datetime(3) NOT NULL DEFAULT (CURRENT_TIMESTAMP(3));
ALTER TABLE `InventoryItem` MODIFY COLUMN `createdAt` datetime(3) NOT NULL DEFAULT (CURRENT_TIMESTAMP(3));--> statement-breakpoint
ALTER TABLE `InventoryItem` MODIFY COLUMN `updatedAt` datetime(3) NOT NULL DEFAULT (CURRENT_TIMESTAMP(3));
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
I guess the generated sql would be the same. we are using planetscale btw
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
Did you try to generate and push from a schema?
33 replies
DTDrizzle Team
Created by focused_morning on 8/23/2023 in #help
Invalid default value for 'updatedAt'
@therealguy_ dropping a table seems a little harsh
33 replies