Skip to content

Commit

Permalink
Add script to seed movies
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeyaworski committed Jul 24, 2024
1 parent 104afdd commit 620f82b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions scripts/seed-movies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import dotenv from 'dotenv';
import { Sequelize } from 'sequelize';

dotenv.config();

const sequelize = new Sequelize(process.env.DATABASE_URL!, {
dialect: 'postgres',
protocol: 'postgres',
logging: false,
});

const numMovies = 1000;
const guildId = '722978838581215253';

async function seed() {
for (let i = 1; i <= numMovies; i++) {
await sequelize.query(`
INSERT INTO movies
(id,guild_id,title,imdb_id,is_favorite, was_watched,"createdAt","updatedAt")
VALUES
(uuid_generate_v4(),'${guildId}','${i}', '${i}',false,false,NOW(),NOW())
;
`).catch(console.error);

Check warning on line 23 in scripts/seed-movies.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
}
process.exit();
}

if (process.env.ENVIRONMENT === 'development') seed();
else console.log('Do not run this on production');

Check warning on line 29 in scripts/seed-movies.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement

0 comments on commit 620f82b

Please sign in to comment.