Add technical; snippet support
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import {DatabaseService, FieldType, Inject, Injectable, Migration, raw} from '@extollo/lib'
|
||||
|
||||
/**
|
||||
* CreatePageViewsTableMigration
|
||||
* ----------------------------------
|
||||
* Table to record analytics data
|
||||
*/
|
||||
@Injectable()
|
||||
export default class CreatePageViewsTableMigration extends Migration {
|
||||
@Inject()
|
||||
protected readonly db!: DatabaseService
|
||||
|
||||
/**
|
||||
* Apply the migration.
|
||||
*/
|
||||
async up(): Promise<void> {
|
||||
const schema = this.db.get().schema()
|
||||
const table = await schema.table('page_views')
|
||||
|
||||
table.primaryKey('page_view_id').required()
|
||||
|
||||
table.column('visited_at')
|
||||
.type(FieldType.timestamp)
|
||||
.default(raw('NOW()'))
|
||||
.required()
|
||||
|
||||
table.column('hostname')
|
||||
.type(FieldType.varchar)
|
||||
.nullable()
|
||||
|
||||
table.column('ip')
|
||||
.type(FieldType.varchar)
|
||||
.nullable()
|
||||
|
||||
table.column('method')
|
||||
.type(FieldType.varchar)
|
||||
.required()
|
||||
|
||||
table.column('endpoint')
|
||||
.type(FieldType.varchar)
|
||||
.required()
|
||||
|
||||
table.column('user_id')
|
||||
.type(FieldType.bigint)
|
||||
.nullable()
|
||||
|
||||
table.column('xhr')
|
||||
.type(FieldType.bool)
|
||||
.default(false)
|
||||
|
||||
await schema.commit(table)
|
||||
}
|
||||
|
||||
/**
|
||||
* Undo the migration.
|
||||
*/
|
||||
async down(): Promise<void> {
|
||||
const schema = this.db.get().schema()
|
||||
const table = await schema.table('page_views')
|
||||
|
||||
table.dropIfExists()
|
||||
|
||||
await schema.commit(table)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import {DatabaseService, FieldType, Inject, Injectable, Migration} from '@extollo/lib'
|
||||
|
||||
/**
|
||||
* CreateSnippetsTableMigration
|
||||
* ----------------------------------
|
||||
* Create table to store code snippets and gists.
|
||||
*/
|
||||
@Injectable()
|
||||
export default class CreateSnippetsTableMigration extends Migration {
|
||||
@Inject()
|
||||
protected readonly db!: DatabaseService
|
||||
|
||||
/**
|
||||
* Apply the migration.
|
||||
*/
|
||||
async up(): Promise<void> {
|
||||
const schema = this.db.get().schema()
|
||||
const table = await schema.table('snippets')
|
||||
|
||||
table.primaryKey('snippet_id').required()
|
||||
|
||||
table.column('slug')
|
||||
.type(FieldType.varchar)
|
||||
.required()
|
||||
|
||||
table.column('users_only')
|
||||
.type(FieldType.bool)
|
||||
.default(false)
|
||||
|
||||
table.column('single_access_only')
|
||||
.type(FieldType.bool)
|
||||
.default(false)
|
||||
|
||||
table.column('access_key')
|
||||
.type(FieldType.varchar)
|
||||
.nullable()
|
||||
|
||||
table.column('syntax')
|
||||
.type(FieldType.varchar)
|
||||
.nullable()
|
||||
|
||||
table.column('body')
|
||||
.type(FieldType.text)
|
||||
.default('')
|
||||
|
||||
await schema.commit(table)
|
||||
}
|
||||
|
||||
/**
|
||||
* Undo the migration.
|
||||
*/
|
||||
async down(): Promise<void> {
|
||||
const schema = this.db.get().schema()
|
||||
const table = await schema.table('snippets')
|
||||
|
||||
table.dropIfExists()
|
||||
|
||||
await schema.commit(table)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user