Initial commit: PC Builder AdonisJS project
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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')
|
||||
table.string('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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'computers'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('title').notNullable()
|
||||
table.integer('state_id').notNullable()
|
||||
table.float('sell_price', 6, 2).nullable()
|
||||
table.integer('gpu_score').notNullable()
|
||||
table.integer('cpu_score').notNullable()
|
||||
table.integer('global_score').notNullable()
|
||||
table.integer('user_id').unsigned().references('id').inTable('users').onDelete('CASCADE')
|
||||
table.timestamp('created_at')
|
||||
table.timestamp('updated_at')
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'component_types'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('name').notNullable()
|
||||
table.boolean('unique').notNullable()
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'components'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('name').notNullable()
|
||||
table.decimal('price', 8, 2).notNullable()
|
||||
table.integer('type_id').unsigned().references('id').inTable('component_types').onDelete('CASCADE')
|
||||
table.integer('computer_id').unsigned().nullable().references('id').inTable('computers').onDelete('CASCADE')
|
||||
table.integer('user_id').unsigned().references('id').inTable('users').onDelete('CASCADE')
|
||||
table.date('purchase_date').notNullable()
|
||||
table.timestamp('created_at')
|
||||
table.timestamp('updated_at')
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'computer_states'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('name').notNullable()
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'computer_pictures'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.integer('computer_id').unsigned().references('id').inTable('computers').onDelete('CASCADE')
|
||||
table.string('link').notNullable()
|
||||
table.integer('order').notNullable()
|
||||
table.timestamp('created_at')
|
||||
table.timestamp('updated_at')
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* This file is automatically generated
|
||||
* DO NOT EDIT manually
|
||||
* Run "node ace migration:run" command to re-generate this file
|
||||
*/
|
||||
|
||||
import { BaseModel, column } from '@adonisjs/lucid/orm'
|
||||
import { DateTime } from 'luxon'
|
||||
|
||||
export class ComponentTypeSchema extends BaseModel {
|
||||
static $columns = ['id', 'name', 'unique'] as const
|
||||
$columns = ComponentTypeSchema.$columns
|
||||
@column({ isPrimary: true })
|
||||
declare id: number
|
||||
@column()
|
||||
declare name: string
|
||||
@column()
|
||||
declare unique: boolean
|
||||
}
|
||||
|
||||
export class ComponentSchema extends BaseModel {
|
||||
static $columns = ['computerId', 'createdAt', 'id', 'name', 'price', 'purchaseDate', 'typeId', 'updatedAt', 'userId'] as const
|
||||
$columns = ComponentSchema.$columns
|
||||
@column()
|
||||
declare computerId: number | null
|
||||
@column.dateTime({ autoCreate: true })
|
||||
declare createdAt: DateTime | null
|
||||
@column({ isPrimary: true })
|
||||
declare id: number
|
||||
@column()
|
||||
declare name: string
|
||||
@column()
|
||||
declare price: string
|
||||
@column.date()
|
||||
declare purchaseDate: DateTime
|
||||
@column()
|
||||
declare typeId: number | null
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
declare updatedAt: DateTime | null
|
||||
@column()
|
||||
declare userId: number | null
|
||||
}
|
||||
|
||||
export class ComputerPictureSchema extends BaseModel {
|
||||
static $columns = ['computerId', 'createdAt', 'id', 'link', 'order', 'updatedAt'] as const
|
||||
$columns = ComputerPictureSchema.$columns
|
||||
@column()
|
||||
declare computerId: number | null
|
||||
@column.dateTime({ autoCreate: true })
|
||||
declare createdAt: DateTime | null
|
||||
@column({ isPrimary: true })
|
||||
declare id: number
|
||||
@column()
|
||||
declare link: string
|
||||
@column()
|
||||
declare order: number
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
declare updatedAt: DateTime | null
|
||||
}
|
||||
|
||||
export class ComputerStateSchema extends BaseModel {
|
||||
static $columns = ['id', 'name'] as const
|
||||
$columns = ComputerStateSchema.$columns
|
||||
@column({ isPrimary: true })
|
||||
declare id: number
|
||||
@column()
|
||||
declare name: string
|
||||
}
|
||||
|
||||
export class ComputerSchema extends BaseModel {
|
||||
static $columns = ['cpuScore', 'createdAt', 'globalScore', 'gpuScore', 'id', 'sellPrice', 'stateId', 'title', 'updatedAt', 'userId'] as const
|
||||
$columns = ComputerSchema.$columns
|
||||
@column()
|
||||
declare cpuScore: number
|
||||
@column.dateTime({ autoCreate: true })
|
||||
declare createdAt: DateTime | null
|
||||
@column()
|
||||
declare globalScore: number
|
||||
@column()
|
||||
declare gpuScore: number
|
||||
@column({ isPrimary: true })
|
||||
declare id: number
|
||||
@column()
|
||||
declare sellPrice: number | null
|
||||
@column()
|
||||
declare stateId: number
|
||||
@column()
|
||||
declare title: string
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
declare updatedAt: DateTime | null
|
||||
@column()
|
||||
declare userId: number | null
|
||||
}
|
||||
|
||||
export class UserSchema extends BaseModel {
|
||||
static $columns = ['createdAt', 'email', 'id', 'name', 'password', 'updatedAt'] as const
|
||||
$columns = UserSchema.$columns
|
||||
@column.dateTime({ autoCreate: true })
|
||||
declare createdAt: DateTime
|
||||
@column()
|
||||
declare email: string
|
||||
@column({ isPrimary: true })
|
||||
declare id: number
|
||||
@column()
|
||||
declare name: string | null
|
||||
@column({ serializeAs: null })
|
||||
declare password: string
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
declare updatedAt: DateTime | null
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { type SchemaRules } from '@adonisjs/lucid/types/schema_generator'
|
||||
|
||||
export default {} satisfies SchemaRules
|
||||
Reference in New Issue
Block a user