feat: create and assign labels on trello import
This commit is contained in:
2
packages/db/migrations/0007_redundant_silver_fox.sql
Normal file
2
packages/db/migrations/0007_redundant_silver_fox.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
DROP INDEX IF EXISTS "unique_slug_per_workspace";--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "unique_slug_per_workspace" ON "board" USING btree ("workspaceId","slug") WHERE "board"."deletedAt" IS NULL;
|
||||
1651
packages/db/migrations/meta/0007_snapshot.json
Normal file
1651
packages/db/migrations/meta/0007_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -50,6 +50,13 @@
|
||||
"when": 1738149668712,
|
||||
"tag": "0006_spicy_mach_iv",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "7",
|
||||
"when": 1738168854269,
|
||||
"tag": "0007_redundant_silver_fox",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -284,8 +284,7 @@ export const isSlugUnique = async (
|
||||
.eq("slug", args.slug)
|
||||
.eq("workspaceId", args.workspaceId)
|
||||
.is("deletedAt", null)
|
||||
.limit(1)
|
||||
.single();
|
||||
.limit(1);
|
||||
|
||||
return !data;
|
||||
return data?.length === 0;
|
||||
};
|
||||
|
||||
@@ -161,6 +161,18 @@ export const createCardLabelRelationship = async (
|
||||
return data;
|
||||
};
|
||||
|
||||
export const bulkCreateCardLabelRelationship = async (
|
||||
db: SupabaseClient<Database>,
|
||||
cardLabelRelationshipInput: { cardId: number; labelId: number }[],
|
||||
) => {
|
||||
const { data } = await db
|
||||
.from("_card_labels")
|
||||
.insert(cardLabelRelationshipInput)
|
||||
.select();
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getCardMemberRelationship = async (
|
||||
db: SupabaseClient<Database>,
|
||||
args: { cardId: number; memberId: number },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
@@ -35,6 +35,21 @@ export const create = async (
|
||||
return data;
|
||||
};
|
||||
|
||||
export const bulkCreate = async (
|
||||
db: SupabaseClient<Database>,
|
||||
labels: {
|
||||
publicId: string;
|
||||
name: string;
|
||||
colourCode: string;
|
||||
boardId: number;
|
||||
createdBy: string;
|
||||
}[],
|
||||
) => {
|
||||
const { data } = await db.from("label").insert(labels).select(`id`);
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getAllByPublicIds = async (
|
||||
db: SupabaseClient<Database>,
|
||||
labelPublicIds: string[],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { relations } from "drizzle-orm";
|
||||
import { relations, sql } from "drizzle-orm";
|
||||
import {
|
||||
bigint,
|
||||
bigserial,
|
||||
@@ -78,10 +78,9 @@ export const boards = pgTable(
|
||||
},
|
||||
(table) => ({
|
||||
visibilityIndex: index("board_visibility_idx").on(table.visibility),
|
||||
uniqueSlugPerWorkspace: uniqueIndex("unique_slug_per_workspace").on(
|
||||
table.workspaceId,
|
||||
table.slug,
|
||||
),
|
||||
uniqueSlugPerWorkspace: uniqueIndex("unique_slug_per_workspace")
|
||||
.on(table.workspaceId, table.slug)
|
||||
.where(sql`${table.deletedAt} IS NULL`),
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user