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)
}
}