mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 07:03:25 +00:00
refactor: use tabs instead of spaces
This commit is contained in:
@@ -2,25 +2,25 @@ import { defaultTableFields } from '#database/default_table_fields';
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema';
|
||||
|
||||
export default class CreateUsersTable extends BaseSchema {
|
||||
static tableName = 'users';
|
||||
static tableName = 'users';
|
||||
|
||||
async up() {
|
||||
this.schema.createTableIfNotExists(CreateUsersTable.tableName, (table) => {
|
||||
table.string('email', 254).notNullable().unique();
|
||||
table.string('name', 254).notNullable();
|
||||
table.string('nick_name', 254).nullable();
|
||||
table.text('avatar_url').notNullable();
|
||||
table.boolean('is_admin').defaultTo(0).notNullable();
|
||||
async up() {
|
||||
this.schema.createTableIfNotExists(CreateUsersTable.tableName, (table) => {
|
||||
table.string('email', 254).notNullable().unique();
|
||||
table.string('name', 254).notNullable();
|
||||
table.string('nick_name', 254).nullable();
|
||||
table.text('avatar_url').notNullable();
|
||||
table.boolean('is_admin').defaultTo(0).notNullable();
|
||||
|
||||
table.json('token').nullable();
|
||||
table.string('provider_id').notNullable();
|
||||
table.enum('provider_type', ['google']).notNullable().defaultTo('google');
|
||||
table.json('token').nullable();
|
||||
table.string('provider_id').notNullable();
|
||||
table.enum('provider_type', ['google']).notNullable().defaultTo('google');
|
||||
|
||||
defaultTableFields(table);
|
||||
});
|
||||
}
|
||||
defaultTableFields(table);
|
||||
});
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(CreateUsersTable.tableName);
|
||||
}
|
||||
async down() {
|
||||
this.schema.dropTable(CreateUsersTable.tableName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,42 +3,42 @@ import { Visibility } from '#enums/visibility';
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema';
|
||||
|
||||
export default class CreateCollectionTable extends BaseSchema {
|
||||
static tableName = 'collections';
|
||||
private visibilityEnumName = 'collection_visibility';
|
||||
static tableName = 'collections';
|
||||
private visibilityEnumName = 'collection_visibility';
|
||||
|
||||
async up() {
|
||||
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
||||
this.schema.createTableIfNotExists(
|
||||
CreateCollectionTable.tableName,
|
||||
(table) => {
|
||||
table.string('name', 254).notNullable();
|
||||
table.string('description', 254).nullable();
|
||||
table
|
||||
.enum('visibility', Object.values(Visibility), {
|
||||
useNative: true,
|
||||
enumName: this.visibilityEnumName,
|
||||
existingType: false,
|
||||
})
|
||||
.nullable()
|
||||
.defaultTo(Visibility.PRIVATE);
|
||||
table
|
||||
.integer('next_id')
|
||||
.references('id')
|
||||
.inTable('collections')
|
||||
.defaultTo(null);
|
||||
table
|
||||
.integer('author_id')
|
||||
.references('id')
|
||||
.inTable('users')
|
||||
.onDelete('CASCADE');
|
||||
async up() {
|
||||
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
||||
this.schema.createTableIfNotExists(
|
||||
CreateCollectionTable.tableName,
|
||||
(table) => {
|
||||
table.string('name', 254).notNullable();
|
||||
table.string('description', 254).nullable();
|
||||
table
|
||||
.enum('visibility', Object.values(Visibility), {
|
||||
useNative: true,
|
||||
enumName: this.visibilityEnumName,
|
||||
existingType: false,
|
||||
})
|
||||
.nullable()
|
||||
.defaultTo(Visibility.PRIVATE);
|
||||
table
|
||||
.integer('next_id')
|
||||
.references('id')
|
||||
.inTable('collections')
|
||||
.defaultTo(null);
|
||||
table
|
||||
.integer('author_id')
|
||||
.references('id')
|
||||
.inTable('users')
|
||||
.onDelete('CASCADE');
|
||||
|
||||
defaultTableFields(table);
|
||||
}
|
||||
);
|
||||
}
|
||||
defaultTableFields(table);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
||||
this.schema.dropTable(CreateCollectionTable.tableName);
|
||||
}
|
||||
async down() {
|
||||
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
||||
this.schema.dropTable(CreateCollectionTable.tableName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,30 +2,30 @@ import { defaultTableFields } from '#database/default_table_fields';
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema';
|
||||
|
||||
export default class CreateLinksTable extends BaseSchema {
|
||||
static tableName = 'links';
|
||||
static tableName = 'links';
|
||||
|
||||
async up() {
|
||||
this.schema.createTableIfNotExists(CreateLinksTable.tableName, (table) => {
|
||||
table.string('name', 254).notNullable();
|
||||
table.string('description', 254).nullable();
|
||||
table.text('url').notNullable();
|
||||
table.boolean('favorite').notNullable().defaultTo(0);
|
||||
table
|
||||
.integer('collection_id')
|
||||
.references('id')
|
||||
.inTable('collections')
|
||||
.onDelete('CASCADE');
|
||||
table
|
||||
.integer('author_id')
|
||||
.references('id')
|
||||
.inTable('users')
|
||||
.onDelete('CASCADE');
|
||||
async up() {
|
||||
this.schema.createTableIfNotExists(CreateLinksTable.tableName, (table) => {
|
||||
table.string('name', 254).notNullable();
|
||||
table.string('description', 254).nullable();
|
||||
table.text('url').notNullable();
|
||||
table.boolean('favorite').notNullable().defaultTo(0);
|
||||
table
|
||||
.integer('collection_id')
|
||||
.references('id')
|
||||
.inTable('collections')
|
||||
.onDelete('CASCADE');
|
||||
table
|
||||
.integer('author_id')
|
||||
.references('id')
|
||||
.inTable('users')
|
||||
.onDelete('CASCADE');
|
||||
|
||||
defaultTableFields(table);
|
||||
});
|
||||
}
|
||||
defaultTableFields(table);
|
||||
});
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(CreateLinksTable.tableName);
|
||||
}
|
||||
async down() {
|
||||
this.schema.dropTable(CreateLinksTable.tableName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema';
|
||||
|
||||
export default class extends BaseSchema {
|
||||
async up() {
|
||||
this.schema.raw(`
|
||||
async up() {
|
||||
this.schema.raw(`
|
||||
CREATE EXTENSION IF NOT EXISTS unaccent;
|
||||
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||
`);
|
||||
this.schema.raw(`
|
||||
this.schema.raw(`
|
||||
CREATE INDEX ON links USING gin(to_tsvector('english', name));
|
||||
CREATE INDEX ON collections USING gin(to_tsvector('english', name));
|
||||
CREATE INDEX ON links USING gin(to_tsvector('french', name));
|
||||
CREATE INDEX ON collections USING gin(to_tsvector('french', name));
|
||||
`);
|
||||
this.schema.raw(`
|
||||
this.schema.raw(`
|
||||
CREATE OR REPLACE FUNCTION search_text(search_query TEXT, p_author_id INTEGER)
|
||||
RETURNS TABLE (
|
||||
id INTEGER,
|
||||
@@ -45,9 +45,9 @@ export default class extends BaseSchema {
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.raw('DROP FUNCTION IF EXISTS search_text');
|
||||
}
|
||||
async down() {
|
||||
this.schema.raw('DROP FUNCTION IF EXISTS search_text');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user