Files
zkopru/packages/database/tests/test-schema.ts
2021-05-10 18:48:20 -05:00

116 lines
2.3 KiB
TypeScript

import { TableData } from '~database'
export default [
{
name: 'TableOne',
primaryKey: 'id',
rows: [
{
name: 'id',
type: 'String',
default: () => Math.floor(Math.random() * 1000000).toString(),
},
['uniqueField', 'String', { unique: true }],
['uniqueAndOptionalField', 'String', { unique: true, optional: true }],
['optionalField', 'String', { optional: true }],
['regularField', 'String'],
],
},
{
name: 'TableTwo',
primaryKey: 'id',
rows: [
{
name: 'id',
type: 'String',
// so this can be meaningfully lexographically sorted
default: () => `${+new Date()}${Math.random()}`,
},
['counterField', 'Int', { unique: true }],
],
},
{
name: 'TableThree',
primaryKey: 'id',
rows: [
{
name: 'id',
type: 'String',
},
{
name: 'optionalField',
type: 'String',
optional: true,
},
],
},
{
name: 'TableFour',
primaryKey: 'id',
rows: [
['id', 'String'],
['relation1Id', 'String', { optional: true }],
{
name: 'relation1',
type: 'String',
relation: {
foreignField: 'id',
localField: 'relation1Id',
foreignTable: 'Relation1',
},
},
],
},
{
name: 'Relation1',
primaryKey: 'id',
rows: [
['id', 'String'],
['relation2Id', 'String'],
{
name: 'relation2',
type: 'String',
relation: {
foreignField: 'id',
localField: 'relation2Id',
foreignTable: 'Relation2',
},
},
],
},
{
name: 'Relation2',
primaryKey: 'id',
rows: [['id', 'String']],
},
{
name: 'Table5',
primaryKey: 'id',
rows: [
['id', 'Int'],
['optionalField', 'Bool', { optional: true }],
],
},
{
name: 'Table6',
primaryKey: 'id',
rows: [
['id', 'Int'],
['boolField', 'Bool'],
['stringField', 'String'],
['objectField', 'Object'],
],
},
{
name: 'Table7',
primaryKey: 'id',
rows: [
['id', 'Int'],
['boolField', 'Bool'],
['stringField', 'String'],
['objectField', 'Object'],
['optionalField', 'String', { optional: true }],
],
},
] as TableData[]