TASKS-1823 WebManager module

This commit is contained in:
Igor Martyniuk
2026-08-28 08:35:58 +00:00
parent fdb2cf3837
commit c93d8c025b
654 changed files with 26232 additions and 6075 deletions
@@ -0,0 +1,57 @@
import { BaseSchema } from '@adonisjs/lucid/schema'
export default class extends BaseSchema {
protected tableName = 'web_pages'
async up() {
this.schema.raw('DROP TYPE IF EXISTS web_page_status_enum')
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table
.enu('status', ['draft', 'published', 'unpublished'], {
useNative: true,
enumName: 'web_page_status_enum',
})
.notNullable()
.defaultTo('draft')
table
.integer('draft_of_id')
.unsigned()
.nullable()
.references('id')
.inTable(this.tableName)
.onDelete('CASCADE')
table.string('locale', 16).notNullable()
table.string('path').notNullable()
table.string('group_key').notNullable()
table.string('page_type').notNullable()
table.string('title').notNullable()
table.jsonb('hero').nullable()
table.string('seo_title').notNullable().defaultTo('')
table.text('seo_description').notNullable().defaultTo('')
table.timestamp('published_at', { useTz: true }).nullable()
table.timestamp('created_at', { useTz: true }).notNullable()
table.timestamp('updated_at', { useTz: true }).notNullable()
table.index(['group_key', 'status'])
table.index(['locale', 'path', 'status'])
})
this.schema.raw(`
CREATE UNIQUE INDEX web_pages_published_route_unique
ON ${this.tableName} (locale, path)
WHERE status = 'published'
`)
this.schema.raw(`
CREATE UNIQUE INDEX web_pages_one_draft_per_page_unique
ON ${this.tableName} (draft_of_id)
WHERE draft_of_id IS NOT NULL
`)
}
async down() {
this.schema.dropTable(this.tableName)
this.schema.raw('DROP TYPE IF EXISTS web_page_status_enum')
}
}
@@ -0,0 +1,29 @@
import { BaseSchema } from '@adonisjs/lucid/schema'
export default class extends BaseSchema {
protected tableName = 'web_components'
async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table
.integer('page_id')
.unsigned()
.notNullable()
.references('id')
.inTable('web_pages')
.onDelete('CASCADE')
table.string('type').notNullable()
table.jsonb('data').notNullable()
table.integer('sort_order').unsigned().notNullable().defaultTo(0)
table.timestamp('created_at', { useTz: true }).notNullable()
table.timestamp('updated_at', { useTz: true }).notNullable()
table.index(['page_id', 'sort_order'])
})
}
async down() {
this.schema.dropTable(this.tableName)
}
}
@@ -0,0 +1,21 @@
import { BaseSchema } from '@adonisjs/lucid/schema'
export default class extends BaseSchema {
protected tableName = 'web_settings'
async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.string('locale', 16).notNullable().unique()
table.jsonb('header').notNullable().defaultTo('{}')
table.jsonb('footer').notNullable().defaultTo('{}')
table.jsonb('legal').notNullable().defaultTo('{}')
table.timestamp('created_at', { useTz: true }).notNullable()
table.timestamp('updated_at', { useTz: true }).notNullable()
})
}
async down() {
this.schema.dropTable(this.tableName)
}
}
-17
View File
@@ -1,17 +0,0 @@
import { BaseSchema } from '@adonisjs/lucid/schema'
export default class extends BaseSchema {
protected tableName = 'testings'
async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.string('name').notNullable().unique()
table.timestamp('created_at')
table.timestamp('updated_at')
})
}
async down() {
this.schema.dropTable(this.tableName)
}
}
+183
View File
@@ -0,0 +1,183 @@
/**
* 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 AdminRoleSchema extends BaseModel {
static $columns = ['adminId', 'createdAt', 'id', 'roleId', 'updatedAt'] as const
$columns = AdminRoleSchema.$columns
@column()
declare adminId: number | null
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime | null
@column({ isPrimary: true })
declare id: number
@column()
declare roleId: number | null
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime | null
}
export class AdminSchema extends BaseModel {
static $columns = ['createdAt', 'email', 'firstName', 'id', 'lastName', 'password', 'status', 'updatedAt'] as const
$columns = AdminSchema.$columns
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime
@column()
declare email: string
@column()
declare firstName: string | null
@column({ isPrimary: true })
declare id: number
@column()
declare lastName: string | null
@column({ serializeAs: null })
declare password: string
@column()
declare status: any
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime | null
}
export class AuthAccessTokenSchema extends BaseModel {
static $columns = ['abilities', 'createdAt', 'expiresAt', 'hash', 'id', 'lastUsedAt', 'name', 'tokenableId', 'type', 'updatedAt'] as const
$columns = AuthAccessTokenSchema.$columns
@column()
declare abilities: string
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime | null
@column.dateTime()
declare expiresAt: DateTime | null
@column()
declare hash: string
@column({ isPrimary: true })
declare id: number
@column.dateTime()
declare lastUsedAt: DateTime | null
@column()
declare name: string | null
@column()
declare tokenableId: number
@column()
declare type: string
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime | null
}
export class PermissionSchema extends BaseModel {
static $columns = ['createdAt', 'id', 'name', 'slug', 'updatedAt'] as const
$columns = PermissionSchema.$columns
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime | null
@column({ isPrimary: true })
declare id: number
@column()
declare name: string
@column()
declare slug: string
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime | null
}
export class RolePermissionSchema extends BaseModel {
static $columns = ['createdAt', 'id', 'permissionSlug', 'roleId', 'updatedAt'] as const
$columns = RolePermissionSchema.$columns
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime | null
@column({ isPrimary: true })
declare id: number
@column()
declare permissionSlug: string | null
@column()
declare roleId: number | null
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime | null
}
export class RoleSchema extends BaseModel {
static $columns = ['createdAt', 'id', 'name', 'updatedAt'] as const
$columns = RoleSchema.$columns
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime | null
@column({ isPrimary: true })
declare id: number
@column()
declare name: string
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime | null
}
export class WebComponentSchema extends BaseModel {
static $columns = ['createdAt', 'data', 'id', 'pageId', 'sortOrder', 'type', 'updatedAt'] as const
$columns = WebComponentSchema.$columns
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime
@column()
declare data: any
@column({ isPrimary: true })
declare id: number
@column()
declare pageId: number
@column()
declare sortOrder: number
@column()
declare type: string
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime
}
export class WebPageSchema extends BaseModel {
static $columns = ['createdAt', 'draftOfId', 'groupKey', 'hero', 'id', 'locale', 'pageType', 'path', 'publishedAt', 'seoDescription', 'seoTitle', 'status', 'title', 'updatedAt'] as const
$columns = WebPageSchema.$columns
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime
@column()
declare draftOfId: number | null
@column()
declare groupKey: string
@column()
declare hero: any | null
@column({ isPrimary: true })
declare id: number
@column()
declare locale: string
@column()
declare pageType: string
@column()
declare path: string
@column.dateTime()
declare publishedAt: DateTime | null
@column()
declare seoDescription: string
@column()
declare seoTitle: string
@column()
declare status: any
@column()
declare title: string
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime
}
export class WebSettingSchema extends BaseModel {
static $columns = ['createdAt', 'footer', 'header', 'id', 'legal', 'locale', 'updatedAt'] as const
$columns = WebSettingSchema.$columns
@column.dateTime({ autoCreate: true })
declare createdAt: DateTime
@column()
declare footer: any
@column()
declare header: any
@column({ isPrimary: true })
declare id: number
@column()
declare legal: any
@column()
declare locale: string
@column.dateTime({ autoCreate: true, autoUpdate: true })
declare updatedAt: DateTime
}