Noita
Noita
DTDrizzle Team
Created by Noita on 2/3/2025 in #help
unique constraint does not seem to be applying as intended.
export const PlayerDiscordCacheTable = pgTable(
`tal_player_discord_cache_table`,
{
id: uuid().defaultRandom().primaryKey(),

playerRef: uuid("player_ref"),

discordRoleIds: text("discord_role_ids").array().default([]),

discordUserName: text("discord_user_name").notNull(),
discordUserId: text("discord_user_id").notNull(),
discordServerId: text("discord_server_id").notNull(),
},
(table) => ({
uniqueServerAndUser: unique("unique_server_and_user").on(
table.discordServerId,
table.discordUserId
)
})
);
export const PlayerDiscordCacheTable = pgTable(
`tal_player_discord_cache_table`,
{
id: uuid().defaultRandom().primaryKey(),

playerRef: uuid("player_ref"),

discordRoleIds: text("discord_role_ids").array().default([]),

discordUserName: text("discord_user_name").notNull(),
discordUserId: text("discord_user_id").notNull(),
discordServerId: text("discord_server_id").notNull(),
},
(table) => ({
uniqueServerAndUser: unique("unique_server_and_user").on(
table.discordServerId,
table.discordUserId
)
})
);
PostgresError: could not create unique index "unique_server_and_user" code: "23505" I also tried with
unique("unique_server_and_user").on(
PlayerDiscordCacheTable.discordServerId,
PlayerDiscordCacheTable.discordUserId
);
unique("unique_server_and_user").on(
PlayerDiscordCacheTable.discordServerId,
PlayerDiscordCacheTable.discordUserId
);
and generate does not seem to see it at all, reporting No schema changes, nothing to migrate :sleeping:. Please let me know if there is any more information I can provide to assist with assitance 🙂 Thanks!
4 replies