-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Include userId in the assets table
- Loading branch information
1 parent
e6d4ff9
commit db2d346
Showing
7 changed files
with
1,235 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CREATE TABLE `assets_new` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`assetType` text NOT NULL, | ||
`bookmarkId` text, | ||
`userId` text NOT NULL, | ||
FOREIGN KEY (`bookmarkId`) REFERENCES `bookmarks`(`id`) ON UPDATE no action ON DELETE cascade | ||
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade | ||
);--> statement-breakpoint | ||
INSERT INTO `assets_new` (`id`, `assetType`, `bookmarkId`, `userId`) SELECT `id`, `assetType`, `bookmarkId`, (select `bookmarks`.`userId` from `bookmarks` where `bookmarks`.`id` = `assets`.`bookmarkId`) FROM `assets`;--> statement-breakpoint | ||
DROP TABLE `assets`;--> statement-breakpoint | ||
ALTER TABLE `assets_new` RENAME TO `assets`;--> statement-breakpoint | ||
CREATE INDEX `assets_bookmarkId_idx` ON `assets` (`bookmarkId`);--> statement-breakpoint | ||
CREATE INDEX `assets_assetType_idx` ON `assets` (`assetType`);--> statement-breakpoint | ||
CREATE INDEX `assets_userId_idx` ON `assets` (`userId`); |
Oops, something went wrong.