migration.sql 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. Warnings:
  3. - You are about to drop the `user` table. If the table is not empty, all the data it contains will be lost.
  4. */
  5. -- DropTable
  6. DROP TABLE `user`;
  7. -- CreateTable
  8. CREATE TABLE `auth` (
  9. `auth_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  10. `username` VARCHAR(191) NOT NULL,
  11. `email` VARCHAR(191) NOT NULL,
  12. `password` VARCHAR(191) NOT NULL,
  13. UNIQUE INDEX `auth_username_key`(`username`),
  14. UNIQUE INDEX `auth_email_key`(`email`),
  15. PRIMARY KEY (`auth_id`)
  16. ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  17. -- CreateTable
  18. CREATE TABLE `userinfo` (
  19. `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  20. `avatar` VARCHAR(191) NOT NULL,
  21. `exp` INTEGER UNSIGNED NOT NULL DEFAULT 0,
  22. `level` INTEGER UNSIGNED NOT NULL DEFAULT 0,
  23. `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
  24. `authId` INTEGER UNSIGNED NOT NULL,
  25. UNIQUE INDEX `userinfo_authId_key`(`authId`),
  26. PRIMARY KEY (`id`)
  27. ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  28. -- AddForeignKey
  29. ALTER TABLE `userinfo` ADD CONSTRAINT `userinfo_authId_fkey` FOREIGN KEY (`authId`) REFERENCES `auth`(`auth_id`) ON DELETE CASCADE ON UPDATE CASCADE;