You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-07 23:03:36 +02:00
refactor: sql-tools (#19717)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { Check, Column, DatabaseConstraintType, DatabaseSchema, Table } from 'src/sql-tools';
|
||||
import { Check, Column, ConstraintType, DatabaseSchema, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
@Check({ expression: '1=1' })
|
||||
@ -9,7 +9,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should create a check constraint with a default name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -33,7 +33,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.CHECK,
|
||||
type: ConstraintType.CHECK,
|
||||
name: 'CHK_8d2ecfd49b984941f6b2589799',
|
||||
tableName: 'table1',
|
||||
expression: '1=1',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Check, Column, DatabaseConstraintType, DatabaseSchema, Table } from 'src/sql-tools';
|
||||
import { Check, Column, ConstraintType, DatabaseSchema, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
@Check({ name: 'CHK_test', expression: '1=1' })
|
||||
@ -9,7 +9,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should create a check constraint with a specific name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -33,7 +33,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.CHECK,
|
||||
type: ConstraintType.CHECK,
|
||||
name: 'CHK_test',
|
||||
tableName: 'table1',
|
||||
expression: '1=1',
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with an created at date column';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a column with a default value (boolean)';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -10,7 +10,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a column with a default value (date)';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a column with a default function';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a nullable column from a default of null';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a column with a default value (number)';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a column with a default value (string)';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a deleted at date column';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -15,7 +15,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should accept an enum type';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { DatabaseConstraintType, DatabaseSchema, PrimaryGeneratedColumn, Table } from 'src/sql-tools';
|
||||
import { ConstraintType, DatabaseSchema, PrimaryGeneratedColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a generated identity column';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -33,7 +33,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_50c4f9905061b1e506d38a2a380',
|
||||
tableName: 'table1',
|
||||
columnNames: ['column1'],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { DatabaseConstraintType, DatabaseSchema, PrimaryGeneratedColumn, Table } from 'src/sql-tools';
|
||||
import { ConstraintType, DatabaseSchema, PrimaryGeneratedColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a primary generated uuid column';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -33,7 +33,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_50c4f9905061b1e506d38a2a380',
|
||||
tableName: 'table1',
|
||||
columnNames: ['column1'],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should create a column with an index';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should create a column with an index if a name is provided';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should infer nullable from the default value';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a column with a default name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a column with a specific name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with a column with a specific name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should set nullable correctly';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should use create a string column with a fixed length';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Column, DatabaseConstraintType, DatabaseSchema, Table } from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should create a unique key constraint with a default name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -32,7 +32,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.UNIQUE,
|
||||
type: ConstraintType.UNIQUE,
|
||||
name: 'UQ_b249cc64cf63b8a22557cdc8537',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Column, DatabaseConstraintType, DatabaseSchema, Table } from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should create a unique key constraint with a specific name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -32,7 +32,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.UNIQUE,
|
||||
type: ConstraintType.UNIQUE,
|
||||
name: 'UQ_test',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
|
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should register a table with an updated at date column';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -0,0 +1,7 @@
|
||||
import { Table } from 'src/sql-tools';
|
||||
|
||||
@Table({ name: 'table-1' })
|
||||
@Table({ name: 'table-2' })
|
||||
export class Table1 {}
|
||||
|
||||
export const message = 'Table table-2 has already been registered';
|
@ -1,11 +1,4 @@
|
||||
import {
|
||||
Column,
|
||||
DatabaseConstraintType,
|
||||
DatabaseSchema,
|
||||
ForeignKeyConstraint,
|
||||
PrimaryColumn,
|
||||
Table,
|
||||
} from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, ForeignKeyConstraint, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -32,7 +25,7 @@ export class Table2 {
|
||||
|
||||
export const description = 'should create a foreign key constraint to the target table';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -65,7 +58,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_e457e8b1301b7bc06ef78188ee4',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id1', 'id2'],
|
||||
@ -108,7 +101,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.FOREIGN_KEY,
|
||||
type: ConstraintType.FOREIGN_KEY,
|
||||
name: 'FK_aed36d04470eba20161aa8b1dc6',
|
||||
tableName: 'table2',
|
||||
columnNames: ['parentId1', 'parentId2'],
|
||||
|
@ -1,11 +1,4 @@
|
||||
import {
|
||||
Column,
|
||||
DatabaseConstraintType,
|
||||
DatabaseSchema,
|
||||
ForeignKeyConstraint,
|
||||
PrimaryColumn,
|
||||
Table,
|
||||
} from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, ForeignKeyConstraint, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -22,7 +15,7 @@ export class Table2 {
|
||||
|
||||
export const description = 'should warn against missing column in foreign key constraint';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -46,7 +39,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_b249cc64cf63b8a22557cdc8537',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
|
@ -1,11 +1,4 @@
|
||||
import {
|
||||
Column,
|
||||
DatabaseConstraintType,
|
||||
DatabaseSchema,
|
||||
ForeignKeyConstraint,
|
||||
PrimaryColumn,
|
||||
Table,
|
||||
} from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, ForeignKeyConstraint, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -22,7 +15,7 @@ export class Table2 {
|
||||
|
||||
export const description = 'should warn against missing reference column in foreign key constraint';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -46,7 +39,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_b249cc64cf63b8a22557cdc8537',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
|
@ -14,7 +14,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should warn against missing reference table';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -1,11 +1,4 @@
|
||||
import {
|
||||
Column,
|
||||
DatabaseConstraintType,
|
||||
DatabaseSchema,
|
||||
ForeignKeyConstraint,
|
||||
PrimaryColumn,
|
||||
Table,
|
||||
} from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, ForeignKeyConstraint, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -28,7 +21,7 @@ export class Table2 {
|
||||
|
||||
export const description = 'should create a foreign key constraint to the target table';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -61,7 +54,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_e457e8b1301b7bc06ef78188ee4',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id1', 'id2'],
|
||||
@ -104,7 +97,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.FOREIGN_KEY,
|
||||
type: ConstraintType.FOREIGN_KEY,
|
||||
name: 'FK_aed36d04470eba20161aa8b1dc6',
|
||||
tableName: 'table2',
|
||||
columnNames: ['parentId1', 'parentId2'],
|
||||
|
@ -1,11 +1,4 @@
|
||||
import {
|
||||
Column,
|
||||
DatabaseConstraintType,
|
||||
DatabaseSchema,
|
||||
ForeignKeyConstraint,
|
||||
PrimaryColumn,
|
||||
Table,
|
||||
} from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, ForeignKeyConstraint, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -22,7 +15,7 @@ export class Table2 {
|
||||
|
||||
export const description = 'should create a foreign key constraint to the target table without an index';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -46,7 +39,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_b249cc64cf63b8a22557cdc8537',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
@ -72,7 +65,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.FOREIGN_KEY,
|
||||
type: ConstraintType.FOREIGN_KEY,
|
||||
name: 'FK_3fcca5cc563abf256fc346e3ff4',
|
||||
tableName: 'table2',
|
||||
columnNames: ['parentId'],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Column, DatabaseConstraintType, DatabaseSchema, ForeignKeyConstraint, Table } from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, ForeignKeyConstraint, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -19,7 +19,7 @@ export class Table2 {
|
||||
|
||||
export const description = 'should create a foreign key constraint to the target table without a primary key';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -69,7 +69,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.FOREIGN_KEY,
|
||||
type: ConstraintType.FOREIGN_KEY,
|
||||
name: 'FK_7d9c784c98d12365d198d52e4e6',
|
||||
tableName: 'table2',
|
||||
columnNames: ['bar'],
|
||||
|
@ -1,11 +1,4 @@
|
||||
import {
|
||||
Column,
|
||||
DatabaseConstraintType,
|
||||
DatabaseSchema,
|
||||
ForeignKeyConstraint,
|
||||
PrimaryColumn,
|
||||
Table,
|
||||
} from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, ForeignKeyConstraint, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -22,7 +15,7 @@ export class Table2 {
|
||||
|
||||
export const description = 'should create a foreign key constraint to the target table';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -46,7 +39,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_b249cc64cf63b8a22557cdc8537',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
@ -80,7 +73,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.FOREIGN_KEY,
|
||||
type: ConstraintType.FOREIGN_KEY,
|
||||
name: 'FK_3fcca5cc563abf256fc346e3ff4',
|
||||
tableName: 'table2',
|
||||
columnNames: ['parentId'],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { DatabaseConstraintType, DatabaseSchema, ForeignKeyColumn, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
import { ConstraintType, DatabaseSchema, ForeignKeyColumn, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -14,7 +14,7 @@ export class Table2 {
|
||||
|
||||
export const description = 'should infer the column type from the reference column';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -38,7 +38,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_b249cc64cf63b8a22557cdc8537',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
@ -72,7 +72,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.FOREIGN_KEY,
|
||||
type: ConstraintType.FOREIGN_KEY,
|
||||
name: 'FK_3fcca5cc563abf256fc346e3ff4',
|
||||
tableName: 'table2',
|
||||
columnNames: ['parentId'],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { DatabaseConstraintType, DatabaseSchema, ForeignKeyColumn, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
import { ConstraintType, DatabaseSchema, ForeignKeyColumn, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -14,7 +14,7 @@ export class Table2 {
|
||||
|
||||
export const description = 'should create a foreign key constraint with a unique constraint';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -38,7 +38,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_b249cc64cf63b8a22557cdc8537',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
@ -72,7 +72,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.FOREIGN_KEY,
|
||||
type: ConstraintType.FOREIGN_KEY,
|
||||
name: 'FK_3fcca5cc563abf256fc346e3ff4',
|
||||
tableName: 'table2',
|
||||
columnNames: ['parentId'],
|
||||
@ -81,7 +81,7 @@ export const schema: DatabaseSchema = {
|
||||
synchronize: true,
|
||||
},
|
||||
{
|
||||
type: DatabaseConstraintType.UNIQUE,
|
||||
type: ConstraintType.UNIQUE,
|
||||
name: 'REL_3fcca5cc563abf256fc346e3ff',
|
||||
tableName: 'table2',
|
||||
columnNames: ['parentId'],
|
||||
|
@ -9,7 +9,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should create an index with a default name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -9,7 +9,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should create an index with a specific name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -9,7 +9,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should create an index based off of an expression';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -9,7 +9,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should create an index with a where clause';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { DatabaseConstraintType, DatabaseSchema, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
import { ConstraintType, DatabaseSchema, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
export class Table1 {
|
||||
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should add a primary key constraint to the table with a default name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -32,7 +32,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_b249cc64cf63b8a22557cdc8537',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { DatabaseConstraintType, DatabaseSchema, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
import { ConstraintType, DatabaseSchema, PrimaryColumn, Table } from 'src/sql-tools';
|
||||
|
||||
@Table({ primaryConstraintName: 'PK_test' })
|
||||
export class Table1 {
|
||||
@ -8,7 +8,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should add a primary key constraint to the table with a specific name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -32,7 +32,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.PRIMARY_KEY,
|
||||
type: ConstraintType.PRIMARY_KEY,
|
||||
name: 'PK_test',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
|
@ -5,7 +5,7 @@ export class Table1 {}
|
||||
|
||||
export const description = 'should register a table with a default name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -5,7 +5,7 @@ export class Table1 {}
|
||||
|
||||
export const description = 'should register a table with a specific name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -5,7 +5,7 @@ export class Table1 {}
|
||||
|
||||
export const description = 'should register a table with a specific name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -16,7 +16,7 @@ export class Table1 {}
|
||||
|
||||
export const description = 'should create a trigger';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [expect.any(Object)],
|
||||
enums: [],
|
||||
|
@ -16,7 +16,7 @@ export class Table1 {}
|
||||
|
||||
export const description = 'should create a trigger ';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [expect.any(Object)],
|
||||
enums: [],
|
||||
|
@ -11,7 +11,7 @@ export class Table1 {}
|
||||
|
||||
export const description = 'should register a trigger with a default name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -12,7 +12,7 @@ export class Table1 {}
|
||||
|
||||
export const description = 'should a trigger with a specific name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Column, DatabaseConstraintType, DatabaseSchema, Table, Unique } from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, Table, Unique } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
@Unique({ columns: ['id'] })
|
||||
@ -9,7 +9,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should add a unique constraint to the table with a default name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -33,7 +33,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.UNIQUE,
|
||||
type: ConstraintType.UNIQUE,
|
||||
name: 'UQ_b249cc64cf63b8a22557cdc8537',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Column, DatabaseConstraintType, DatabaseSchema, Table, Unique } from 'src/sql-tools';
|
||||
import { Column, ConstraintType, DatabaseSchema, Table, Unique } from 'src/sql-tools';
|
||||
|
||||
@Table()
|
||||
@Unique({ name: 'UQ_test', columns: ['id'] })
|
||||
@ -9,7 +9,7 @@ export class Table1 {
|
||||
|
||||
export const description = 'should add a unique constraint to the table with a specific name';
|
||||
export const schema: DatabaseSchema = {
|
||||
name: 'postgres',
|
||||
databaseName: 'postgres',
|
||||
schemaName: 'public',
|
||||
functions: [],
|
||||
enums: [],
|
||||
@ -33,7 +33,7 @@ export const schema: DatabaseSchema = {
|
||||
triggers: [],
|
||||
constraints: [
|
||||
{
|
||||
type: DatabaseConstraintType.UNIQUE,
|
||||
type: ConstraintType.UNIQUE,
|
||||
name: 'UQ_test',
|
||||
tableName: 'table1',
|
||||
columnNames: ['id'],
|
||||
|
Reference in New Issue
Block a user