Skip to content

Commit 692868b

Browse files
committed
Merge branch 'main' of github.com:civitai/civitai into main
2 parents d21e838 + 126c2b8 commit 692868b

37 files changed

+1009
-377
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "model-share",
3-
"version": "5.0.584",
3+
"version": "5.0.587",
44
"private": true,
55
"scripts": {
66
"start": "next start",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE "AuctionBase"
2+
ADD COLUMN "runForDays" INTEGER NOT NULL DEFAULT 1,
3+
ADD COLUMN "validForDays" INTEGER NOT NULL DEFAULT 1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
ALTER TYPE "HomeBlockType" ADD VALUE 'FeaturedModelVersion';
2+
3+
DROP MATERIALIZED VIEW IF EXISTS "CoveredCheckpointDetails";
4+
5+
/*
6+
For history:
7+
8+
create materialized view "CoveredCheckpointDetails" as
9+
WITH
10+
newest AS (
11+
SELECT
12+
mv_1."modelId",
13+
min(mv_1.index) AS index
14+
FROM "ModelVersion" mv_1
15+
WHERE
16+
mv_1."baseModel" = ANY
17+
(ARRAY ['SD 1.5'::text, 'SD 1.4'::text, 'SD 1.5 LCM'::text, 'SDXL 0.9'::text, 'SDXL 1.0'::text, 'SDXL 1.0 LCM'::text, 'Pony'::text, 'Illustrious'::text, 'SD 3.5'::text, 'SD 3.5 Medium'::text, 'SD 3.5 Large'::text, 'SD 3.5 Large Turbo'::text])
18+
GROUP BY mv_1."modelId"
19+
)
20+
SELECT
21+
mv.id AS version_id,
22+
m.name AS model,
23+
mv.name AS version,
24+
CASE
25+
WHEN cc.version_id IS NULL THEN 'latest only'::text
26+
ELSE 'specific version'::text
27+
END AS type,
28+
mv."baseModel"
29+
FROM "CoveredCheckpoint" cc
30+
JOIN "Model" m ON m.id = cc.model_id
31+
JOIN newest n ON n."modelId" = cc.model_id
32+
JOIN "ModelVersion" mv ON cc.version_id = mv.id OR
33+
cc.version_id IS NULL AND mv."modelId" = cc.model_id AND mv.index = n.index AND mv.status = 'Published'::"ModelStatus";
34+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
-- auto-generated definition
2+
create table if not exists "CoveredCheckpoint"
3+
(
4+
model_id integer not null,
5+
version_id integer
6+
);
7+
8+
alter table "CoveredCheckpoint"
9+
alter column version_id set not null;
10+
11+
create unique index if not exists "CoveredCheckpoint_modelVersion"
12+
on "CoveredCheckpoint" (model_id, version_id);
13+
14+
alter table "CoveredCheckpoint"
15+
drop constraint if exists "CoveredCheckpoint_model_id_fkey";
16+
alter table "CoveredCheckpoint"
17+
add constraint "CoveredCheckpoint_model_id_fkey"
18+
foreign key (model_id) references "Model" (id)
19+
on delete cascade
20+
on update cascade;
21+
22+
alter table "CoveredCheckpoint"
23+
drop constraint if exists "CoveredCheckpoint_version_id_fkey";
24+
alter table "CoveredCheckpoint"
25+
add constraint "CoveredCheckpoint_version_id_fkey"
26+
foreign key (version_id) references "ModelVersion" (id)
27+
on delete cascade
28+
on update cascade;
29+
30+
-- driveby
31+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "ChatMember_chatId_idx" ON "ChatMember" ("chatId");
32+
33+
create or replace view "GenerationCoverage"("modelId", "modelVersionId", covered) as
34+
SELECT
35+
m.id AS "modelId",
36+
mv.id AS "modelVersionId",
37+
true AS covered
38+
FROM "ModelVersion" mv
39+
JOIN "Model" m ON m.id = mv."modelId"
40+
WHERE
41+
(mv.id = ANY
42+
(ARRAY [
43+
1475084, -- BiRefNet Background Removal
44+
164821, -- Remacri
45+
128713, -- DreamShaper
46+
128078, -- SDXL
47+
391999, -- SDXL Lightning LoRAs
48+
424706, -- LCM-LoRA Weights
49+
106916, -- Civitai Safe Helper
50+
250712, -- safe_neg
51+
250708, -- safe_pos
52+
691639, -- FLUX Dev
53+
699279, -- FLUX Schnell
54+
699332, -- FLUX Pro
55+
922358, -- FLUX Pro 1.1
56+
1088507, -- FLUX Pro 1.1 Ultra
57+
1003708, -- SD 3.5 Medium
58+
983309, -- SD 3.5 Large
59+
983611, -- SD 3.5 Large Turbo
60+
1190596, -- NoobAI-XL
61+
290640, -- Pony
62+
889818 -- Illustrious
63+
]))
64+
OR (mv."baseModel" = ANY
65+
(ARRAY ['SD 1.5'::text, 'SD 1.4'::text, 'SD 1.5 LCM'::text, 'SDXL 0.9'::text, 'SDXL 1.0'::text, 'SDXL 1.0 LCM'::text, 'Pony'::text, 'Flux.1 D'::text, 'Illustrious'::text, 'SD 3.5'::text, 'SD 3.5 Medium'::text, 'SD 3.5 Large'::text, 'SD 3.5 Large Turbo'::text, 'NoobAI'::text])) AND
66+
NOT m.poi AND
67+
(mv.status = 'Published'::"ModelStatus" OR m.availability = 'Private'::"Availability" OR m."uploadType" = 'Trained'::"ModelUploadType") AND
68+
m."allowCommercialUse" && ARRAY ['RentCivit'::"CommercialUse", 'Rent'::"CommercialUse", 'Sell'::"CommercialUse"] AND
69+
(m.type = 'Checkpoint'::"ModelType" AND mv."baseModelType" = 'Standard'::text AND (mv.id IN (
70+
SELECT
71+
"CoveredCheckpoint".version_id
72+
FROM "CoveredCheckpoint"
73+
)) OR m.type = 'LORA'::"ModelType" OR m.type = 'TextualInversion'::"ModelType" OR m.type = 'VAE'::"ModelType" OR m.type = 'LoCon'::"ModelType" OR
74+
m.type = 'DoRA'::"ModelType") AND (EXISTS (
75+
SELECT
76+
1
77+
FROM "ModelFile" mf
78+
WHERE
79+
mf."modelVersionId" = mv.id
80+
AND (mf."scannedAt" IS NOT NULL AND (mf.type = ANY (ARRAY ['Model'::text, 'Pruned Model'::text, 'Negative'::text, 'VAE'::text])) OR
81+
(mf.metadata -> 'trainingResults'::text) IS NOT NULL)
82+
));

prisma/schema.prisma

+22-8
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ model Model {
657657
collectionItems CollectionItem[]
658658
generationCoverage GenerationCoverage[]
659659
flags ModelFlag[]
660+
coveredCheckpoints CoveredCheckpoint[]
660661
661662
@@index([name])
662663
@@index([status, nsfw])
@@ -805,6 +806,7 @@ model ModelVersion {
805806
DonationGoal DonationGoal[]
806807
featuredInfo FeaturedModelVersion[]
807808
ImageResourceNew ImageResourceNew[]
809+
coveredCheckpoints CoveredCheckpoint[]
808810
809811
@@index([modelId], type: Hash)
810812
}
@@ -2575,6 +2577,7 @@ enum HomeBlockType {
25752577
Social
25762578
Event
25772579
CosmeticShop
2580+
FeaturedModelVersion
25782581
}
25792582

25802583
model HomeBlock {
@@ -3383,15 +3386,17 @@ enum AuctionType {
33833386
}
33843387

33853388
model AuctionBase {
3386-
id Int @id @default(autoincrement())
3387-
type AuctionType
3388-
ecosystem String? // like Pony, SDXL, etc
3389-
name String
3390-
slug String
3391-
quantity Int // propagates to individual item
3392-
minPrice Int // propagates to individual item
3389+
id Int @id @default(autoincrement())
3390+
type AuctionType
3391+
ecosystem String? // like Pony, SDXL, etc
3392+
name String
3393+
slug String
3394+
quantity Int // propagates to individual item
3395+
minPrice Int // propagates to individual item
33933396
// buyItNowPrices Json? // would probably need to be JSON to support different slot costs...
3394-
active Boolean @default(true)
3397+
active Boolean @default(true)
3398+
runForDays Int @default(1)
3399+
validForDays Int @default(1)
33953400
33963401
auctions Auction[]
33973402
recurringBids BidRecurring[]
@@ -3462,6 +3467,15 @@ model FeaturedModelVersion {
34623467
position Int
34633468
}
34643469

3470+
model CoveredCheckpoint {
3471+
model_id Int
3472+
version_id Int
3473+
model Model @relation(fields: [model_id], references: [id], onDelete: Cascade)
3474+
modelVersion ModelVersion @relation(fields: [version_id], references: [id], onDelete: Cascade)
3475+
3476+
@@unique([model_id, version_id])
3477+
}
3478+
34653479
enum ModerationRuleAction {
34663480
Approve
34673481
Block

0 commit comments

Comments
 (0)