Initial commit
This commit is contained in:
64
database/seeders/main_seeder.js
Normal file
64
database/seeders/main_seeder.js
Normal file
@@ -0,0 +1,64 @@
|
||||
import { BaseSeeder } from '@adonisjs/lucid/seeders';
|
||||
import { DateTime } from 'luxon';
|
||||
import User from '#models/user';
|
||||
import Information from '#models/information';
|
||||
import Music from '#models/music';
|
||||
import Category from '#models/category';
|
||||
import Tag from '#models/tag';
|
||||
import Training from '#models/training';
|
||||
import Project from '#models/project';
|
||||
import hash from '@adonisjs/core/services/hash';
|
||||
export default class extends BaseSeeder {
|
||||
async run() {
|
||||
await User.updateOrCreate({ email: 'admin@portfolio.local' }, {
|
||||
email: 'admin@portfolio.local',
|
||||
password: await hash.make('admin123'),
|
||||
fullName: 'Admin',
|
||||
});
|
||||
const info = await Information.first();
|
||||
if (!info) {
|
||||
await Information.create({
|
||||
name: 'John Doe',
|
||||
headline: 'Développeur Full Stack',
|
||||
contact: 'john@example.com',
|
||||
linkedin: 'https://linkedin.com/in/johndoe',
|
||||
github: 'https://github.com/johndoe',
|
||||
birthday: DateTime.fromISO('1990-01-15'),
|
||||
});
|
||||
}
|
||||
else {
|
||||
await info.merge({
|
||||
name: 'John Doe',
|
||||
headline: 'Développeur Full Stack',
|
||||
contact: 'john@example.com',
|
||||
linkedin: 'https://linkedin.com/in/johndoe',
|
||||
github: 'https://github.com/johndoe',
|
||||
birthday: DateTime.fromISO('1990-01-15'),
|
||||
}).save();
|
||||
}
|
||||
const catWeb = await Category.updateOrCreate({ name: 'Web' }, { name: 'Web' });
|
||||
await Category.updateOrCreate({ name: 'Mobile' }, { name: 'Mobile' });
|
||||
const tagJs = await Tag.updateOrCreate({ name: 'JavaScript' }, { name: 'JavaScript', color: '#f7df1e' });
|
||||
const tagTs = await Tag.updateOrCreate({ name: 'TypeScript' }, { name: 'TypeScript', color: '#3178c6' });
|
||||
const training1 = await Training.updateOrCreate({ name: 'Formation AdonisJS' }, {
|
||||
name: 'Formation AdonisJS',
|
||||
start: DateTime.fromISO('2024-01-01'),
|
||||
end: DateTime.fromISO('2024-06-01'),
|
||||
skill: 'Backend',
|
||||
place: 'En ligne',
|
||||
});
|
||||
const project1 = await Project.updateOrCreate({ title: 'Mon Portfolio' }, {
|
||||
title: 'Mon Portfolio',
|
||||
content: '# Mon Portfolio\n\nUn site portfolio moderne.',
|
||||
start: DateTime.fromISO('2024-01-01'),
|
||||
end: DateTime.fromISO('2024-03-01'),
|
||||
thumbnailUrl: '/uploads/thumb1.jpg',
|
||||
categoryId: catWeb.id,
|
||||
});
|
||||
await project1.related('tags').sync([tagJs.id, tagTs.id]);
|
||||
await project1.related('trainings').sync([training1.id]);
|
||||
await Music.updateOrCreate({ name: 'Track 1' }, { name: 'Track 1', url: '/music/track1.mp3' });
|
||||
await Music.updateOrCreate({ name: 'Track 2' }, { name: 'Track 2', url: '/music/track2.mp3' });
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=main_seeder.js.map
|
||||
Reference in New Issue
Block a user