diff --git a/models/band.ts b/models/band.ts index c9e14ff..33aee82 100644 --- a/models/band.ts +++ b/models/band.ts @@ -30,7 +30,9 @@ const BandSchema = new mongoose.Schema({ ], }); -hasMigrated && BandSchema.plugin(AutoIncrement, { id: "band" }); +hasMigrated && + !mongoose.models.Band && + BandSchema.plugin(AutoIncrement, { id: "band" }); export const Band: Model = /* mongoose.models.Band || */ model( "Band", BandSchema, diff --git a/models/challenges/biffno.ts b/models/challenges/biffno.ts index 1dfab5a..18372f9 100644 --- a/models/challenges/biffno.ts +++ b/models/challenges/biffno.ts @@ -68,6 +68,7 @@ const biffnoschema = new mongoose.Schema({ }); hasMigrated && + !mongoose.models.Biffno && biffnoschema.plugin(AutoIncrement, { start_seq: 1, id: "bif_id" }); export const Biffno: Model = mongoose.models.Biffno || mongoose.model("Biffno", biffnoschema, "biffno"); diff --git a/models/challenges/ficmas.ts b/models/challenges/ficmas.ts index ab66b57..10f8a76 100644 --- a/models/challenges/ficmas.ts +++ b/models/challenges/ficmas.ts @@ -49,6 +49,7 @@ export const FicmasSchema = new mongoose.Schema({ }); hasMigrated && + !mongoose.models.Ficmas && FicmasSchema.plugin(AutoIncrement, { id: "ficmas_wishes", inc_field: "_id" }); export const Ficmas: Model = diff --git a/models/challenges/gen.ts b/models/challenges/gen.ts index c46e74d..7626bbe 100644 --- a/models/challenges/gen.ts +++ b/models/challenges/gen.ts @@ -45,7 +45,9 @@ const challengeSchema = new mongoose.Schema({ }, }); -hasMigrated && challengeSchema.plugin(AutoIncrement, { id: "challenges" }); +hasMigrated && + !mongoose.models.Challenge && + challengeSchema.plugin(AutoIncrement, { id: "challenges" }); export const Challenge: Model = // mongoose.models.Challenge || mongoose.model("Challenge", challengeSchema, "challenges"); diff --git a/models/privMsg.ts b/models/privMsg.ts index 1e96355..025937b 100644 --- a/models/privMsg.ts +++ b/models/privMsg.ts @@ -50,7 +50,9 @@ const PMSchema = new mongoose.Schema({ }, }); -hasMigrated && PMSchema.plugin(AutoIncrement, { id: "private_message" }); +hasMigrated && + !mongoose.models.PrivMsg && + PMSchema.plugin(AutoIncrement, { id: "private_message" }); export const PrivMsg: Model = /* mongoose.models.PrivMsg || */ mongoose.model( diff --git a/models/stories/draft.ts b/models/stories/draft.ts index f6a7889..16b99f8 100644 --- a/models/stories/draft.ts +++ b/models/stories/draft.ts @@ -39,7 +39,9 @@ const DraftSchema = new Schema( { timestamps: true }, ); -hasMigrated && DraftSchema.plugin(AutoIncrement, { id: "drafts" }); +hasMigrated && + !mongoose.models.Draft && + DraftSchema.plugin(AutoIncrement, { id: "drafts" }); export const Draft: Model = /* mongoose.models.Draft || */ mongoose.model("Draft", DraftSchema, "drafts"); diff --git a/models/stories/index.ts b/models/stories/index.ts index 9177ad6..222f400 100644 --- a/models/stories/index.ts +++ b/models/stories/index.ts @@ -88,6 +88,7 @@ const StorySchema = new mongoose.Schema({ }, }); hasMigrated && + !mongoose.models.Story && Chapter.plugin(AutoIncrement, { id: "chapterid", inc_field: "id" }); hasMigrated && StorySchema.plugin(AutoIncrement, { id: "storyid" }); export const Story: Model = diff --git a/models/stories/review.ts b/models/stories/review.ts index f16cd2c..8d0cc5a 100644 --- a/models/stories/review.ts +++ b/models/stories/review.ts @@ -72,7 +72,9 @@ CommentSchema populateSelected("author", "User", "profile username _id blocked"), ); -hasMigrated && CommentSchema.plugin(AutoIncrement, { id: "reviews" }); +hasMigrated && + !mongoose.models.Review && + CommentSchema.plugin(AutoIncrement, { id: "reviews" }); export const Review: Model = /* mongoose.models.Review || */ mongoose.model( diff --git a/models/user.ts b/models/user.ts index 41204a4..b53c548 100644 --- a/models/user.ts +++ b/models/user.ts @@ -293,5 +293,6 @@ UserSchema.methods.generateJWT = function (jwtKey: string): string { }; hasMigrated && + !mongoose.models.User && UserSchema.plugin(AutoIncrement, { id: "userid", inc_field: "_id" }); export const User = mongoose.model("User", UserSchema, "users");