diff --git a/adonis-typings/seeder.ts b/adonis-typings/seeder.ts index 6cac5559..b7c77888 100644 --- a/adonis-typings/seeder.ts +++ b/adonis-typings/seeder.ts @@ -15,6 +15,7 @@ declare module '@ioc:Adonis/Lucid/Seeder' { */ export type SeederConstructorContract = { developmentOnly: boolean + environment: string[] new (client: QueryClientContract): { client: QueryClientContract run(): Promise diff --git a/src/SeedsRunner/index.ts b/src/SeedsRunner/index.ts index dc9dc301..355df9a2 100644 --- a/src/SeedsRunner/index.ts +++ b/src/SeedsRunner/index.ts @@ -58,10 +58,9 @@ export class SeedsRunner { } /** - * Ignore when running in non-development environment and seeder is development - * only + * Ignore when when the node environement is not the same as the seeder configuration. */ - if (Source.developmentOnly && !this.app.inDev) { + if (Source.developmentOnly && !this.app.inDev || Source.environment && !Source.environment.includes(this.app.nodeEnvironment)) { seeder.status = 'ignored' return seeder }