diff --git a/prisma/migrations/20220916130117_add_capabilities_project/migration.sql b/prisma/migrations/20220916130117_add_capabilities_project/migration.sql new file mode 100644 index 0000000..dd8f200 --- /dev/null +++ b/prisma/migrations/20220916130117_add_capabilities_project/migration.sql @@ -0,0 +1,38 @@ +-- AlterTable +ALTER TABLE "Project" ADD COLUMN "discord" TEXT NOT NULL DEFAULT E'', +ADD COLUMN "github" TEXT NOT NULL DEFAULT E'', +ADD COLUMN "hashtag" TEXT NOT NULL DEFAULT E'', +ADD COLUMN "launch_status" TEXT NOT NULL DEFAULT E'', +ADD COLUMN "tagline" TEXT NOT NULL DEFAULT E'', +ADD COLUMN "twitter" TEXT NOT NULL DEFAULT E''; + +-- CreateTable +CREATE TABLE "Capability" ( + "id" SERIAL NOT NULL, + "title" TEXT NOT NULL, + "icon" TEXT, + "is_official" BOOLEAN NOT NULL DEFAULT false, + + CONSTRAINT "Capability_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "_CapabilityToProject" ( + "A" INTEGER NOT NULL, + "B" INTEGER NOT NULL +); + +-- CreateIndex +CREATE UNIQUE INDEX "Capability_title_key" ON "Capability"("title"); + +-- CreateIndex +CREATE UNIQUE INDEX "_CapabilityToProject_AB_unique" ON "_CapabilityToProject"("A", "B"); + +-- CreateIndex +CREATE INDEX "_CapabilityToProject_B_index" ON "_CapabilityToProject"("B"); + +-- AddForeignKey +ALTER TABLE "_CapabilityToProject" ADD FOREIGN KEY ("A") REFERENCES "Capability"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_CapabilityToProject" ADD FOREIGN KEY ("B") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20220918072708_update_project_links_fields/migration.sql b/prisma/migrations/20220918072708_update_project_links_fields/migration.sql new file mode 100644 index 0000000..3b23f83 --- /dev/null +++ b/prisma/migrations/20220918072708_update_project_links_fields/migration.sql @@ -0,0 +1,18 @@ +/* + Warnings: + + - You are about to drop the column `is_official` on the `Capability` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "Capability" DROP COLUMN "is_official"; + +-- AlterTable +ALTER TABLE "Project" ADD COLUMN "slack" TEXT, +ADD COLUMN "telegram" TEXT, +ALTER COLUMN "discord" DROP NOT NULL, +ALTER COLUMN "discord" DROP DEFAULT, +ALTER COLUMN "github" DROP NOT NULL, +ALTER COLUMN "github" DROP DEFAULT, +ALTER COLUMN "twitter" DROP NOT NULL, +ALTER COLUMN "twitter" DROP DEFAULT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 5003892..1808c83 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -131,6 +131,11 @@ model Project { screenshots String[] screenshots_ids Int[] website String + discord String? + twitter String? + github String? + telegram String? + slack String? thumbnail_image String? thumbnail_image_id Int? @unique thumbnail_image_rel HostedImage? @relation("Project_Thumbnail", fields: [thumbnail_image_id], references: [id]) @@ -139,14 +144,18 @@ model Project { cover_image_rel HostedImage? @relation("Project_CoverImage", fields: [cover_image_id], references: [id]) lightning_address String? lnurl_callback_url String? + tagline String @default("") + launch_status String @default("") + hashtag String @default("") category Category @relation(fields: [category_id], references: [id]) category_id Int votes_count Int @default(0) createdAt DateTime @default(now()) - awards Award[] - tags Tag[] + awards Award[] + tags Tag[] + capabilities Capability[] recruit_roles ProjectRecruitRoles[] tournaments TournamentProject[] @@ -409,3 +418,13 @@ model TournamentProject { @@id([tournament_id, project_id]) } + +// ----------------- +// Capability +// ----------------- +model Capability { + id Int @id @default(autoincrement()) + title String @unique + icon String? + project Project[] +} diff --git a/prisma/seed/data.js b/prisma/seed/data.js index cc482df..9ebd9e4 100644 --- a/prisma/seed/data.js +++ b/prisma/seed/data.js @@ -510,6 +510,54 @@ const skills = [ }, ] +const capabilities = [ + { + id: 1, + title: 'Mobile', + icon: '📱' + }, + { + id: 2, + title: 'Web', + icon: '💻' + }, + { + id: 3, + title: 'WebLN', + icon: '🎛️' + }, + { + id: 4, + title: 'LNURL-auth', + icon: '🔑️️' + }, + { + id: 5, + title: 'LNURL-pay', + icon: '💸' + }, + { + id: 6, + title: 'LNURL-channel', + icon: '🕳️️' + }, + { + id: 7, + title: 'LNURL-withdraw', + icon: '🎬️' + }, + { + id: 8, + title: 'BOLT 11', + icon: '⚡' + }, + { + id: 9, + title: 'BOLT 12', + icon: '⚡' + }, +] + module.exports = { categories, projects, @@ -517,4 +565,5 @@ module.exports = { hackathons, roles, skills, + capabilities, } \ No newline at end of file diff --git a/prisma/seed/index.js b/prisma/seed/index.js index beb24cd..2c51ee4 100644 --- a/prisma/seed/index.js +++ b/prisma/seed/index.js @@ -1,6 +1,6 @@ const { PrismaClient } = require("@prisma/client"); const { generatePrivateKey, getPublicKey } = require("../../api/utils/nostr-tools"); -const { categories, projects, tags, hackathons, roles, skills } = require("./data"); +const { categories, projects, tags, hackathons, roles, skills, capabilities } = require("./data"); const Chance = require('chance'); const { getCoverImage, randomItems, random } = require("./helpers"); const { tournament: tournamentMock } = require("./data/tournament.seed"); @@ -67,7 +67,9 @@ async function main() { // await createTournament(); - await migrateOldImages(); + // await migrateOldImages(); + + await createCapabilities(); } async function migrateOldImages() { @@ -499,6 +501,13 @@ async function createTournament() { } +async function createCapabilities() { + console.log("Creating Capabilities"); + await prisma.capability.createMany({ + data: capabilities + }) +} + main() .catch((e) => {