Add fullstack example

This commit is contained in:
Mike Conrad
2025-06-11 16:15:52 -04:00
parent f98e05b677
commit 1a58bc3220
40 changed files with 8639 additions and 634 deletions

View File

@ -0,0 +1,21 @@
import { BaseSchema } from '@adonisjs/lucid/schema'
export default class extends BaseSchema {
protected tableName = 'users'
async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').notNullable()
table.string('full_name').nullable()
table.string('email', 254).notNullable().unique()
table.string('password').notNullable()
table.timestamp('created_at').notNullable()
table.timestamp('updated_at').nullable()
})
}
async down() {
this.schema.dropTable(this.tableName)
}
}

View File

@ -0,0 +1,15 @@
import User from '#models/user'
import { BaseSeeder } from '@adonisjs/lucid/seeders'
import { faker } from '@faker-js/faker'
export default class extends BaseSeeder {
public async run () {
const users = Array.from({ length: 1000 }).map(() => ({
fullName: faker.person.fullName(),
email: faker.internet.email(),
password: 'password123',
}))
await User.createMany(users)
}
}