-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(envited.ascs.digital): Save member categories (#118)
- Loading branch information
Showing
19 changed files
with
940 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 19 additions & 1 deletion
20
apps/envited.ascs.digital/common/database/queries/businessCategories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
import { businessCategory } from '../schema' | ||
import { eq } from 'drizzle-orm' | ||
|
||
import { businessCategory, profilesToBusinessCategories } from '../schema' | ||
import { DatabaseConnection } from '../types' | ||
|
||
export const getBusinessCategories = (db: DatabaseConnection) => async () => db.select().from(businessCategory) | ||
|
||
export const getBusinessCategoriesByProfileId = (db: DatabaseConnection) => async (profileId: string) => | ||
db | ||
.select({ businessCategoryId: profilesToBusinessCategories.businessCategoryId }) | ||
.from(profilesToBusinessCategories) | ||
.where(eq(profilesToBusinessCategories.profileId, profileId)) | ||
|
||
export const insertBusinessCategoryByProfileId = | ||
(db: DatabaseConnection) => async (profileId: string, businessCategoryId: string) => | ||
db.insert(profilesToBusinessCategories).values({ | ||
profileId, | ||
businessCategoryId, | ||
}) | ||
|
||
export const deleteBusinessCategoriesByProfileId = (db: DatabaseConnection) => async (profileId: string) => | ||
db.delete(profilesToBusinessCategories).where(eq(profilesToBusinessCategories.profileId, profileId)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
apps/envited.ascs.digital/drizzle/development/0010_third_fallen_one.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
ALTER TABLE "profile" DROP CONSTRAINT "profile_name_user_name_fk"; | ||
--> statement-breakpoint | ||
ALTER TABLE "profilesToBusinessCategories" DROP CONSTRAINT "profilesToBusinessCategories_profile_id_profile_id_fk"; | ||
--> statement-breakpoint | ||
ALTER TABLE "user" DROP CONSTRAINT "user_issuer_id_issuer_id_fk"; | ||
--> statement-breakpoint | ||
ALTER TABLE "usersToCredentialTypes" DROP CONSTRAINT "usersToCredentialTypes_user_id_user_id_fk"; | ||
--> statement-breakpoint | ||
ALTER TABLE "usersToRoles" DROP CONSTRAINT "usersToRoles_user_id_user_id_fk"; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "profile" ADD CONSTRAINT "profile_name_user_name_fk" FOREIGN KEY ("name") REFERENCES "user"("name") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "profilesToBusinessCategories" ADD CONSTRAINT "profilesToBusinessCategories_profile_id_profile_id_fk" FOREIGN KEY ("profile_id") REFERENCES "profile"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "user" ADD CONSTRAINT "user_issuer_id_issuer_id_fk" FOREIGN KEY ("issuer_id") REFERENCES "issuer"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "usersToCredentialTypes" ADD CONSTRAINT "usersToCredentialTypes_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "usersToRoles" ADD CONSTRAINT "usersToRoles_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |
Oops, something went wrong.