mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-02-05 14:17:49 +01:00
24
app/Models/Announce.ts
Normal file
24
app/Models/Announce.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import {DateTime} from 'luxon'
|
||||||
|
import {BaseModel, BelongsTo, belongsTo, column, HasOne, hasOne} from '@ioc:Adonis/Lucid/Orm'
|
||||||
|
import File from "App/Models/File";
|
||||||
|
import Translation from "App/Models/Translation";
|
||||||
|
|
||||||
|
export default class Announce extends BaseModel {
|
||||||
|
@column({ isPrimary: true })
|
||||||
|
public id: number
|
||||||
|
|
||||||
|
@belongsTo(() => Translation)
|
||||||
|
public message: BelongsTo<typeof Translation>
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public messageId: number
|
||||||
|
|
||||||
|
@hasOne(() => File)
|
||||||
|
public cover: HasOne<typeof File>
|
||||||
|
|
||||||
|
@column.dateTime({ autoCreate: true })
|
||||||
|
public createdAt: DateTime
|
||||||
|
|
||||||
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||||
|
public updatedAt: DateTime
|
||||||
|
}
|
||||||
22
app/Models/Profile.ts
Normal file
22
app/Models/Profile.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import {DateTime} from 'luxon'
|
||||||
|
import {BaseModel, column} from '@ioc:Adonis/Lucid/Orm'
|
||||||
|
|
||||||
|
export default class Profile extends BaseModel {
|
||||||
|
@column({ isPrimary: true })
|
||||||
|
public id: number
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public age: number
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public hiringStatus: string
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public hiringColor: string
|
||||||
|
|
||||||
|
@column.dateTime({ autoCreate: true })
|
||||||
|
public createdAt: DateTime
|
||||||
|
|
||||||
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||||
|
public updatedAt: DateTime
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { DateTime } from 'luxon'
|
import {DateTime} from 'luxon'
|
||||||
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
|
import {BaseModel, column, HasOne, hasOne} from '@ioc:Adonis/Lucid/Orm'
|
||||||
|
import File from "App/Models/File";
|
||||||
|
|
||||||
export default class Project extends BaseModel {
|
export default class Project extends BaseModel {
|
||||||
@column({ isPrimary: true })
|
@column({ isPrimary: true })
|
||||||
@@ -17,6 +18,9 @@ export default class Project extends BaseModel {
|
|||||||
@column()
|
@column()
|
||||||
public url: string
|
public url: string
|
||||||
|
|
||||||
|
@hasOne(() => File)
|
||||||
|
public cover: HasOne<typeof File>
|
||||||
|
|
||||||
@column.dateTime({ autoCreate: true })
|
@column.dateTime({ autoCreate: true })
|
||||||
public createdAt: DateTime
|
public createdAt: DateTime
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
import { DateTime } from 'luxon'
|
|
||||||
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
|
|
||||||
|
|
||||||
export default class Song extends BaseModel {
|
|
||||||
@column({ isPrimary: true })
|
|
||||||
public id: number
|
|
||||||
|
|
||||||
@column()
|
|
||||||
public author: string
|
|
||||||
|
|
||||||
@column()
|
|
||||||
public album: string
|
|
||||||
|
|
||||||
@column()
|
|
||||||
public title: string
|
|
||||||
|
|
||||||
@column()
|
|
||||||
public type: string
|
|
||||||
|
|
||||||
@column()
|
|
||||||
public device: string
|
|
||||||
|
|
||||||
@column()
|
|
||||||
public duration: number
|
|
||||||
|
|
||||||
@column.date()
|
|
||||||
public releaseDate: DateTime
|
|
||||||
|
|
||||||
@column.dateTime({ autoCreate: true })
|
|
||||||
public createdAt: DateTime
|
|
||||||
|
|
||||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
||||||
public updatedAt: DateTime
|
|
||||||
}
|
|
||||||
22
app/Models/Translation.ts
Normal file
22
app/Models/Translation.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import {DateTime} from 'luxon'
|
||||||
|
import {BaseModel, column} from '@ioc:Adonis/Lucid/Orm'
|
||||||
|
|
||||||
|
export default class Translation extends BaseModel {
|
||||||
|
@column({ isPrimary: true })
|
||||||
|
public id: number
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public code: string
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public french: string
|
||||||
|
|
||||||
|
@column()
|
||||||
|
public english: string
|
||||||
|
|
||||||
|
@column.dateTime({ autoCreate: true })
|
||||||
|
public createdAt: DateTime
|
||||||
|
|
||||||
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||||
|
public updatedAt: DateTime
|
||||||
|
}
|
||||||
17
database/migrations/1603020084373_subscribers.ts
Normal file
17
database/migrations/1603020084373_subscribers.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class Subscribers extends BaseSchema {
|
||||||
|
protected tableName = 'subscribers'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id').primary()
|
||||||
|
table.string('email').notNullable()
|
||||||
|
table.timestamps(true, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
18
database/migrations/1605956543449_files.ts
Normal file
18
database/migrations/1605956543449_files.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class Pictures extends BaseSchema {
|
||||||
|
protected tableName = 'files'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id').primary()
|
||||||
|
table.string('label').notNullable()
|
||||||
|
table.string('file_name').notNullable()
|
||||||
|
table.timestamps(true, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
18
database/migrations/1605956711010_posts.ts
Normal file
18
database/migrations/1605956711010_posts.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class Posts extends BaseSchema {
|
||||||
|
protected tableName = 'posts'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id').primary()
|
||||||
|
table.string('slug').notNullable()
|
||||||
|
table.integer('likes').notNullable()
|
||||||
|
table.timestamps(true, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
19
database/migrations/1608409476823_locations.ts
Normal file
19
database/migrations/1608409476823_locations.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class Locations extends BaseSchema {
|
||||||
|
protected tableName = 'locations'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id').primary()
|
||||||
|
table.string('place')
|
||||||
|
table.string('left')
|
||||||
|
table.date('since')
|
||||||
|
table.timestamps(true, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
20
database/migrations/1608415261417_projects.ts
Normal file
20
database/migrations/1608415261417_projects.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class Projects extends BaseSchema {
|
||||||
|
protected tableName = 'projects'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id').primary()
|
||||||
|
table.string('name')
|
||||||
|
table.string('description')
|
||||||
|
table.string('url')
|
||||||
|
table.integer('progress')
|
||||||
|
table.timestamps(true, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
20
database/migrations/1618661863952_forms.ts
Normal file
20
database/migrations/1618661863952_forms.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class Forms extends BaseSchema {
|
||||||
|
protected tableName = 'forms'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id').primary()
|
||||||
|
table.string('name')
|
||||||
|
table.string('email')
|
||||||
|
table.string('subject')
|
||||||
|
table.string('content')
|
||||||
|
table.timestamps(true, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
36
database/migrations/1625078903131_users.ts
Normal file
36
database/migrations/1625078903131_users.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
import Hash from "@ioc:Adonis/Core/Hash";
|
||||||
|
|
||||||
|
export default class Users extends BaseSchema {
|
||||||
|
protected tableName = 'users'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id').primary()
|
||||||
|
table.string('username', 255).notNullable()
|
||||||
|
table.string('email', 255).notNullable()
|
||||||
|
table.string('password', 180).defaultTo(this.randomPassword()).notNullable()
|
||||||
|
table.boolean('is_confirmed').defaultTo(false).notNullable()
|
||||||
|
table.string('remember_me_token').defaultTo(null).nullable()
|
||||||
|
table.string('confirmation_token').defaultTo(null).nullable()
|
||||||
|
table.timestamps(true, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
|
||||||
|
private randomPassword(): string {
|
||||||
|
let password = ''
|
||||||
|
const char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!.:=+-_$*^&@#%ù/àçè()é"'
|
||||||
|
const size = 64
|
||||||
|
for (let i = 0; i < size; i++) {
|
||||||
|
password += char.charAt(Math.random() * char.length)
|
||||||
|
}
|
||||||
|
Hash.make(password).then((value => {
|
||||||
|
password = value
|
||||||
|
}))
|
||||||
|
return password
|
||||||
|
}
|
||||||
|
}
|
||||||
21
database/migrations/1625078908619_api_tokens.ts
Normal file
21
database/migrations/1625078908619_api_tokens.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class ApiTokens extends BaseSchema {
|
||||||
|
protected tableName = 'api_tokens'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id').primary()
|
||||||
|
table.integer('user_id').unsigned().references('id').inTable('users').onDelete('CASCADE')
|
||||||
|
table.string('name').notNullable()
|
||||||
|
table.string('type').notNullable()
|
||||||
|
table.string('token', 64).notNullable()
|
||||||
|
table.timestamp('expires_at', { useTz: true }).nullable()
|
||||||
|
table.timestamps(true, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
19
database/migrations/1628110081266_translations.ts
Normal file
19
database/migrations/1628110081266_translations.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class Translations extends BaseSchema {
|
||||||
|
protected tableName = 'translations'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id')
|
||||||
|
table.string('code').notNullable()
|
||||||
|
table.string('french').defaultTo('Traduction manquante')
|
||||||
|
table.string('code').defaultTo('Missing translation')
|
||||||
|
table.timestamps(true, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
19
database/migrations/1628110086918_profiles.ts
Normal file
19
database/migrations/1628110086918_profiles.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class Profiles extends BaseSchema {
|
||||||
|
protected tableName = 'profiles'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
|
table.increments('id')
|
||||||
|
table.integer('age').notNullable()
|
||||||
|
table.string('hiring_color').notNullable()
|
||||||
|
table.string('hiring_status').notNullable()
|
||||||
|
table.timestamps(true, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.dropTable(this.tableName)
|
||||||
|
}
|
||||||
|
}
|
||||||
17
database/migrations/1628110400158_projects.ts
Normal file
17
database/migrations/1628110400158_projects.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
|
||||||
|
export default class Projects extends BaseSchema {
|
||||||
|
protected tableName = 'projects'
|
||||||
|
|
||||||
|
public async up () {
|
||||||
|
this.schema.table(this.tableName, (table) => {
|
||||||
|
table.integer('cover_id').unsigned().references('files.id').onDelete('CASCADE')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down () {
|
||||||
|
this.schema.table(this.tableName, (table) => {
|
||||||
|
table.dropColumn('cover_id')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
"@adonisjs/ally": "^4.1.0",
|
"@adonisjs/ally": "^4.1.0",
|
||||||
"@adonisjs/auth": "^8.0.6",
|
"@adonisjs/auth": "^8.0.6",
|
||||||
"@adonisjs/bouncer": "^2.2.4",
|
"@adonisjs/bouncer": "^2.2.4",
|
||||||
"@adonisjs/core": "~5.1.8",
|
"@adonisjs/core": "^5.1.10",
|
||||||
"@adonisjs/lucid": "^15.0.1",
|
"@adonisjs/lucid": "^15.0.1",
|
||||||
"@adonisjs/mail": "^7.2.1",
|
"@adonisjs/mail": "^7.2.1",
|
||||||
"@adonisjs/redis": "^7.0.6",
|
"@adonisjs/redis": "^7.0.6",
|
||||||
|
|||||||
Reference in New Issue
Block a user