Help, issue that will drop our user table

We generated and pushed our schemas to a dev branch in planetscale, and then deployed that branch no issue. One of the schemas was the User schema. We added two schemas to our db and pushed to dev again, no changes were made to the User schema, yet pushing to the dev db wants to truncate our user table because of the createdAt and updatedAt columns. What is happening and what should we do? Schema
export const user = mysqlTable(
'User',
{
id: varchar('id', { length: 191 }).primaryKey().notNull(),
username: varchar('username', { length: 191 }),
profileImageUrl: varchar('profileImageUrl', { length: 191 }),
email: varchar('email', { length: 191 }),
bio: text('bio'),
headline: text('headline'),
website: varchar('website', { length: 191 }),
twitter: varchar('twitter', { length: 191 }),
instagram: varchar('instagram', { length: 191 }),
opensea: varchar('opensea', { length: 191 }),
membershipTier: mysqlEnum('membershipTier', [
'COMMON',
'RARE',
'EPIC',
'LEGENDARY',
'PN',
]),
role: mysqlEnum('role', ['ADMIN', 'CREATOR', 'USER'])
.default('USER')
.notNull(),
createdAt: datetime('createdAt', { mode: 'string', fsp: 3 })
.default(sql`(CURRENT_TIMESTAMP(3))`)
.notNull(),
updatedAt: datetime('updatedAt', { mode: 'string', fsp: 3 })
.default(sql`(CURRENT_TIMESTAMP(3))`)
.notNull(),
},
(table) => {
return {
usernameIdx: index('User_username_idx').on(table.username),
usernameKey: uniqueIndex('User_username_key').on(table.username),
}
},
)
export const user = mysqlTable(
'User',
{
id: varchar('id', { length: 191 }).primaryKey().notNull(),
username: varchar('username', { length: 191 }),
profileImageUrl: varchar('profileImageUrl', { length: 191 }),
email: varchar('email', { length: 191 }),
bio: text('bio'),
headline: text('headline'),
website: varchar('website', { length: 191 }),
twitter: varchar('twitter', { length: 191 }),
instagram: varchar('instagram', { length: 191 }),
opensea: varchar('opensea', { length: 191 }),
membershipTier: mysqlEnum('membershipTier', [
'COMMON',
'RARE',
'EPIC',
'LEGENDARY',
'PN',
]),
role: mysqlEnum('role', ['ADMIN', 'CREATOR', 'USER'])
.default('USER')
.notNull(),
createdAt: datetime('createdAt', { mode: 'string', fsp: 3 })
.default(sql`(CURRENT_TIMESTAMP(3))`)
.notNull(),
updatedAt: datetime('updatedAt', { mode: 'string', fsp: 3 })
.default(sql`(CURRENT_TIMESTAMP(3))`)
.notNull(),
},
(table) => {
return {
usernameIdx: index('User_username_idx').on(table.username),
usernameKey: uniqueIndex('User_username_key').on(table.username),
}
},
)
1 Reply
focused_morning
focused_morningOP15mo ago
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;
Want results from more Discord servers?
Add your server