drizzle-orm 0.9.13 → 0.9.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable max-classes-per-file */
2
3
  /* eslint-disable import/no-named-as-default-member */
3
4
  /* eslint-disable import/no-named-as-default */
4
5
  /* eslint-disable no-param-reassign */
@@ -34,7 +35,7 @@ class MigrationSerializer {
34
35
  if (value instanceof columns_1.Column) {
35
36
  columnToReturn[value.getColumnName()] = {
36
37
  name: value.getColumnName(),
37
- type: value.isAutoIncrement() ? 'serial' : value.getColumnType().getDbName(),
38
+ type: value.getColumnType().getDbName(),
38
39
  primaryKey: !!value.primaryKeyName,
39
40
  unique: !!value.uniqueKeyName,
40
41
  default: value.getDefaultValue() === null ? undefined : value.getDefaultValue(),
@@ -69,6 +70,172 @@ class MigrationSerializer {
69
70
  }, {});
70
71
  return { version: '1', tables: result, enums: enumsToReturn };
71
72
  };
73
+ this.fromDatabase = async (db) => {
74
+ var _a;
75
+ const result = {};
76
+ const allTables = await db.session().execute('SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema != \'pg_catalog\' and table_schema != \'information_schema\';');
77
+ for await (const row of allTables.rows) {
78
+ try {
79
+ // const tableSchema = row.table_schema;
80
+ const tableName = row.table_name;
81
+ const columnToReturn = {};
82
+ const indexToReturn = {};
83
+ const tableResponse = await db.session().execute(`SELECT a.attrelid::regclass::text, a.attname
84
+ , CASE WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[])
85
+ AND EXISTS (
86
+ SELECT FROM pg_attrdef ad
87
+ WHERE ad.adrelid = a.attrelid
88
+ AND ad.adnum = a.attnum
89
+ AND pg_get_expr(ad.adbin, ad.adrelid)
90
+ = 'nextval('''
91
+ || (pg_get_serial_sequence (a.attrelid::regclass::text
92
+ , a.attname))::regclass
93
+ || '''::regclass)'
94
+ )
95
+ THEN CASE a.atttypid
96
+ WHEN 'int'::regtype THEN 'serial'
97
+ WHEN 'int8'::regtype THEN 'bigserial'
98
+ WHEN 'int2'::regtype THEN 'smallserial'
99
+ END
100
+ ELSE format_type(a.atttypid, a.atttypmod)
101
+ END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name, INFORMATION_SCHEMA.COLUMNS.column_name, INFORMATION_SCHEMA.COLUMNS.column_default
102
+ FROM pg_attribute a
103
+ JOIN INFORMATION_SCHEMA.COLUMNS ON INFORMATION_SCHEMA.COLUMNS.column_name = a.attname
104
+ WHERE a.attrelid = '${tableName}'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}'
105
+ AND a.attnum > 0
106
+ AND NOT a.attisdropped
107
+ ORDER BY a.attnum;`);
108
+ const tableConstraints = await db.session().execute(`SELECT c.column_name, c.data_type, constraint_type, constraint_name
109
+ FROM information_schema.table_constraints tc
110
+ JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
111
+ JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema
112
+ AND tc.table_name = c.table_name AND ccu.column_name = c.column_name
113
+ WHERE tc.table_name = '${tableName}';`);
114
+ const tableForeignKeys = await db.session().execute(`SELECT
115
+ tc.table_schema,
116
+ tc.constraint_name,
117
+ tc.table_name,
118
+ kcu.column_name,
119
+ ccu.table_schema AS foreign_table_schema,
120
+ ccu.table_name AS foreign_table_name,
121
+ ccu.column_name AS foreign_column_name,
122
+ rc.delete_rule, rc.update_rule
123
+ FROM
124
+ information_schema.table_constraints AS tc
125
+ JOIN information_schema.key_column_usage AS kcu
126
+ ON tc.constraint_name = kcu.constraint_name
127
+ AND tc.table_schema = kcu.table_schema
128
+ JOIN information_schema.constraint_column_usage AS ccu
129
+ ON ccu.constraint_name = tc.constraint_name
130
+ AND ccu.table_schema = tc.table_schema
131
+ JOIN information_schema.referential_constraints AS rc
132
+ ON ccu.constraint_name = rc.constraint_name
133
+ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name='${tableName}';`);
134
+ const mappedRefernces = {};
135
+ for (const fk of tableForeignKeys.rows) {
136
+ // const tableFrom = fk.table_name;
137
+ const columnFrom = fk.column_name;
138
+ const tableTo = fk.foreign_table_name;
139
+ const columnTo = fk.foreign_column_name;
140
+ const foreignKeyName = fk.constraint_name;
141
+ const onUpdate = fk.update_rule;
142
+ const onDelete = fk.delete_rule;
143
+ mappedRefernces[columnFrom] = {
144
+ foreignKeyName,
145
+ table: tableTo,
146
+ column: columnTo,
147
+ onDelete: onUpdate ? `ON UPDATE ${onUpdate}` : undefined,
148
+ onUpdate: onDelete ? `ON DELETE ${onDelete}` : undefined,
149
+ };
150
+ }
151
+ for (const columnResponse of tableResponse.rows) {
152
+ const columnName = columnResponse.attname;
153
+ const columnType = columnResponse.data_type;
154
+ const primaryKey = tableConstraints.rows.filter((mapRow) => columnName === mapRow.column_name && mapRow.constraint_type === 'PRIMARY KEY');
155
+ const uniqueKey = tableConstraints.rows.filter((mapRow) => columnName === mapRow.column_name && mapRow.constraint_type === 'UNIQUE');
156
+ const defaultValue = columnResponse.column_default === null
157
+ ? undefined : columnResponse.column_default;
158
+ const isSerial = columnType === 'serial';
159
+ columnToReturn[columnName] = {
160
+ name: columnName,
161
+ type: columnType,
162
+ primaryKey: !!primaryKey[0],
163
+ unique: !!uniqueKey[0],
164
+ default: isSerial ? undefined : defaultValue,
165
+ notNull: !columnResponse.is_nullable,
166
+ references: (_a = mappedRefernces[columnName]) !== null && _a !== void 0 ? _a : undefined,
167
+ };
168
+ }
169
+ const dbIndexes = await db.session().execute(`select
170
+ t.relname as table_name,
171
+ i.relname as index_name,
172
+ a.attname as column_name
173
+ from
174
+ pg_class t,
175
+ pg_class i,
176
+ pg_index ix,
177
+ pg_attribute a
178
+ where
179
+ t.oid = ix.indrelid
180
+ and i.oid = ix.indexrelid
181
+ and a.attrelid = t.oid
182
+ and a.attnum = ANY(ix.indkey)
183
+ and t.relkind = 'r'
184
+ and t.relname = '${tableName}'
185
+ order by
186
+ t.relname,
187
+ i.relname;`);
188
+ for (const dbIndex of dbIndexes.rows) {
189
+ const indexName = dbIndex.index_name;
190
+ const indexColumnName = dbIndex.column_name;
191
+ if (indexToReturn[indexName] !== undefined && indexToReturn[indexName] !== null) {
192
+ indexToReturn[indexName].columns[indexColumnName] = {
193
+ name: indexColumnName,
194
+ };
195
+ }
196
+ else {
197
+ indexToReturn[indexName] = {
198
+ name: indexName,
199
+ columns: {
200
+ [indexColumnName]: {
201
+ name: indexColumnName,
202
+ },
203
+ },
204
+ };
205
+ }
206
+ }
207
+ result[tableName] = {
208
+ name: tableName,
209
+ columns: columnToReturn,
210
+ indexes: indexToReturn,
211
+ };
212
+ }
213
+ catch (e) {
214
+ console.log(e);
215
+ }
216
+ }
217
+ const allEnums = await db.session().execute(`select n.nspname as enum_schema,
218
+ t.typname as enum_name,
219
+ e.enumlabel as enum_value
220
+ from pg_type t
221
+ join pg_enum e on t.oid = e.enumtypid
222
+ join pg_catalog.pg_namespace n ON n.oid = t.typnamespace;`);
223
+ const enumsToReturn = {};
224
+ for (const dbEnum of allEnums.rows) {
225
+ const enumName = dbEnum.enum_name;
226
+ const enumValue = dbEnum.enum_value;
227
+ if (enumsToReturn[enumName] !== undefined && enumsToReturn[enumName] !== null) {
228
+ enumsToReturn[enumName].values.push(enumValue);
229
+ }
230
+ else {
231
+ enumsToReturn[enumName] = {
232
+ name: enumName,
233
+ values: [enumValue],
234
+ };
235
+ }
236
+ }
237
+ return { version: '1', tables: result, enums: enumsToReturn };
238
+ };
72
239
  }
73
240
  }
74
241
  exports.default = MigrationSerializer;
@@ -11,7 +11,7 @@ import InsertTRB from '../builders/highLvlBuilders/insertRequestBuilder';
11
11
  import DeleteTRB from '../builders/highLvlBuilders/deleteRequestBuilder';
12
12
  import UpdateTRB from '../builders/highLvlBuilders/updateRequestBuilder';
13
13
  import SelectTRB from '../builders/highLvlBuilders/selectRequestBuilder';
14
- import PgBigInt from '../columns/types/pgBigInt';
14
+ import PgBigInt53, { PgBigInt64 } from '../columns/types/pgBigInt';
15
15
  import BaseLogger from '../logger/abstractLogger';
16
16
  import PgEnum from '../columns/types/pgEnum';
17
17
  import DB from '../db/db';
@@ -19,6 +19,9 @@ import { AbstractColumn, Column } from '../columns/column';
19
19
  import TableIndex from '../indexes/tableIndex';
20
20
  import { ExtractModel } from './inferTypes';
21
21
  import Enum, { ExtractEnumValues } from '../types/type';
22
+ import PgSerial from '../columns/types/pgSerial';
23
+ import PgTimestamptz from '../columns/types/pgTimestamptz';
24
+ import PgBigSerial53, { PgBigSerial64 } from '../columns/types/pgBigSerial';
22
25
  export default abstract class AbstractTable<TTable extends AbstractTable<TTable>> {
23
26
  db: DB;
24
27
  private _session;
@@ -43,102 +46,23 @@ export default abstract class AbstractTable<TTable extends AbstractTable<TTable>
43
46
  protected uniqueIndex(columns: Column<ColumnType, boolean, boolean>): TableIndex;
44
47
  protected varchar(name: string, params?: {
45
48
  size?: number;
46
- notNull: false;
47
49
  }): Column<PgVarChar, true>;
48
- protected varchar(name: string, params: {
49
- size?: number;
50
- notNull: true;
51
- }): Column<PgVarChar, false>;
52
- protected varchar(name: string, params?: {
53
- size?: number;
54
- notNull?: false;
55
- }): Column<PgVarChar, true>;
56
- protected varchar(name: string, params: {
57
- size?: number;
58
- notNull?: true;
59
- }): Column<PgVarChar, false>;
60
- protected int(name: string, params?: {
61
- notNull: false;
62
- }): Column<PgInteger, true>;
63
- protected int(name: string, params: {
64
- notNull: true;
65
- }): Column<PgInteger, false>;
66
- protected smallInt(name: string, params?: {
67
- notNull: false;
68
- }): Column<PgInteger, true>;
69
- protected smallInt(name: string, params: {
70
- notNull: true;
71
- }): Column<PgInteger, false>;
72
- protected timestamp(name: string, params?: {
73
- notNull: false;
74
- }): Column<PgTimestamp, true>;
75
- protected timestamp(name: string, params: {
76
- notNull: true;
77
- }): Column<PgTimestamp, false>;
78
- protected bigint(name: string, params?: {
79
- notNull: false;
80
- }): Column<PgBigInt, true>;
81
- protected bigint(name: string, params: {
82
- notNull: true;
83
- }): Column<PgBigInt, false>;
84
- protected type<ETtype extends string>(typeEnum: Enum<ETtype>, name: string, params?: {
85
- notNull: false;
86
- }): Column<PgEnum<ExtractEnumValues<Enum<ETtype>>>, true>;
87
- protected type<ETtype extends string>(typeEnum: Enum<ETtype>, name: string, params: {
88
- notNull: true;
89
- }): Column<PgEnum<ExtractEnumValues<Enum<ETtype>>>, false>;
50
+ protected int(name: string): Column<PgInteger, true>;
51
+ protected smallInt(name: string): Column<PgInteger, true>;
52
+ protected serial(name: string): Column<PgSerial, true, true>;
53
+ protected bigSerial(name: string, maxBytes: 'max_bytes_53'): Column<PgBigSerial53, true, true>;
54
+ protected bigSerial(name: string, maxBytes: 'max_bytes_64'): Column<PgBigSerial64, true, true>;
55
+ protected timestamp(name: string): Column<PgTimestamp, true>;
56
+ protected timestamptz(name: string): Column<PgTimestamptz, true>;
57
+ protected bigint(name: string, maxBytes: 'max_bytes_53'): Column<PgBigInt53, true, true>;
58
+ protected bigint(name: string, maxBytes: 'max_bytes_64'): Column<PgBigInt64, true, true>;
59
+ protected type<ETtype extends string>(typeEnum: Enum<ETtype>, name: string): Column<PgEnum<ExtractEnumValues<Enum<ETtype>>>, true>;
90
60
  protected decimal(name: string, params?: {
91
61
  precision?: number;
92
- scale: number;
93
- notNull?: false;
94
- }): Column<PgBigDecimal, true>;
95
- protected decimal(name: string, params: {
96
- precision?: number;
97
- scale: number;
98
- notNull?: true;
99
- }): Column<PgBigDecimal, false>;
100
- protected decimal(name: string, params?: {
101
- precision: number;
102
62
  scale?: number;
103
- notNull?: false;
104
63
  }): Column<PgBigDecimal, true>;
105
- protected decimal(name: string, params: {
106
- precision: number;
107
- scale?: number;
108
- notNull?: true;
109
- }): Column<PgBigDecimal, false>;
110
- protected decimal(name: string, params?: {
111
- precision?: number;
112
- scale?: number;
113
- notNull?: false;
114
- }): Column<PgBigDecimal, true>;
115
- protected decimal(name: string, params: {
116
- precision?: number;
117
- scale?: number;
118
- notNull?: true;
119
- }): Column<PgBigDecimal, false>;
120
- protected time(name: string, params?: {
121
- notNull: false;
122
- }): Column<PgTime, true>;
123
- protected time(name: string, params: {
124
- notNull: true;
125
- }): Column<PgTime, false>;
126
- protected bool(name: string, params?: {
127
- notNull: false;
128
- }): Column<PgBoolean, true>;
129
- protected bool(name: string, params: {
130
- notNull: true;
131
- }): Column<PgBoolean, false>;
132
- protected text(name: string, params?: {
133
- notNull: false;
134
- }): Column<PgText, true>;
135
- protected text(name: string, params: {
136
- notNull: true;
137
- }): Column<PgText, false>;
138
- protected jsonb<TSubType>(name: string, params?: {
139
- notNull: false;
140
- }): Column<PgJsonb<TSubType>, true>;
141
- protected jsonb<TSubType>(name: string, params: {
142
- notNull: true;
143
- }): Column<PgJsonb<TSubType>, false>;
64
+ protected time(name: string): Column<PgTime, true>;
65
+ protected bool(name: string): Column<PgBoolean, true>;
66
+ protected text(name: string): Column<PgText, true>;
67
+ protected jsonb<TSubType>(name: string): Column<PgJsonb<TSubType>, true>;
144
68
  }
@@ -17,6 +17,9 @@ const pgEnum_1 = require("../columns/types/pgEnum");
17
17
  const column_1 = require("../columns/column");
18
18
  const tableIndex_1 = require("../indexes/tableIndex");
19
19
  const pgSmallInt_1 = require("../columns/types/pgSmallInt");
20
+ const pgSerial_1 = require("../columns/types/pgSerial");
21
+ const pgTimestamptz_1 = require("../columns/types/pgTimestamptz");
22
+ const pgBigSerial_1 = require("../columns/types/pgBigSerial");
20
23
  class AbstractTable {
21
24
  constructor(db) {
22
25
  this.withLogger = (logger) => {
@@ -73,49 +76,53 @@ class AbstractTable {
73
76
  return new tableIndex_1.default(this.tableName(), columns instanceof Array ? columns : [columns]);
74
77
  }
75
78
  varchar(name, params = {}) {
76
- var _a;
77
- return new column_1.Column(this, name, new pgVarChar_1.default(params.size), (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
79
+ return new column_1.Column(this, name, new pgVarChar_1.default(params.size));
78
80
  }
79
- int(name, params = {}) {
80
- var _a;
81
- return new column_1.Column(this, name, new pgInteger_1.default(), (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
81
+ int(name) {
82
+ return new column_1.Column(this, name, new pgInteger_1.default());
82
83
  }
83
- smallInt(name, params = {}) {
84
- var _a;
85
- return new column_1.Column(this, name, new pgSmallInt_1.default(), (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
84
+ smallInt(name) {
85
+ return new column_1.Column(this, name, new pgSmallInt_1.default());
86
86
  }
87
- timestamp(name, params = {}) {
88
- var _a;
89
- return new column_1.Column(this, name, new pgTimestamp_1.default(), (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
87
+ serial(name) {
88
+ return new column_1.Column(this, name, new pgSerial_1.default());
90
89
  }
91
- bigint(name, params = {}) {
92
- var _a;
93
- return new column_1.Column(this, name, new pgBigInt_1.default(), (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
90
+ bigSerial(name, maxBytes) {
91
+ if (maxBytes === 'max_bytes_53') {
92
+ return new column_1.Column(this, name, new pgBigSerial_1.default());
93
+ }
94
+ return new column_1.Column(this, name, new pgBigSerial_1.PgBigSerial64());
95
+ }
96
+ timestamp(name) {
97
+ return new column_1.Column(this, name, new pgTimestamp_1.default());
98
+ }
99
+ timestamptz(name) {
100
+ return new column_1.Column(this, name, new pgTimestamptz_1.default());
101
+ }
102
+ bigint(name, maxBytes) {
103
+ if (maxBytes === 'max_bytes_53') {
104
+ return new column_1.Column(this, name, new pgBigInt_1.default());
105
+ }
106
+ return new column_1.Column(this, name, new pgBigInt_1.PgBigInt64());
94
107
  }
95
- type(typeEnum, name, params = {}) {
96
- var _a;
108
+ type(typeEnum, name) {
97
109
  const pgEnum = new pgEnum_1.default(typeEnum.name);
98
- return new column_1.Column(this, name, pgEnum, (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
110
+ return new column_1.Column(this, name, pgEnum);
99
111
  }
100
112
  decimal(name, params = {}) {
101
- var _a;
102
- return new column_1.Column(this, name, new pgBigDecimal_1.default(params.precision, params.scale), (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
113
+ return new column_1.Column(this, name, new pgBigDecimal_1.default(params.precision, params.scale));
103
114
  }
104
- time(name, params = {}) {
105
- var _a;
106
- return new column_1.Column(this, name, new pgTime_1.default(), (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
115
+ time(name) {
116
+ return new column_1.Column(this, name, new pgTime_1.default());
107
117
  }
108
- bool(name, params = {}) {
109
- var _a;
110
- return new column_1.Column(this, name, new pgBoolean_1.default(), (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
118
+ bool(name) {
119
+ return new column_1.Column(this, name, new pgBoolean_1.default());
111
120
  }
112
- text(name, params = {}) {
113
- var _a;
114
- return new column_1.Column(this, name, new pgText_1.default(), (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
121
+ text(name) {
122
+ return new column_1.Column(this, name, new pgText_1.default());
115
123
  }
116
- jsonb(name, params = {}) {
117
- var _a;
118
- return new column_1.Column(this, name, new pgJsonb_1.default(), (_a = !(params === null || params === void 0 ? void 0 : params.notNull)) !== null && _a !== void 0 ? _a : false);
124
+ jsonb(name) {
125
+ return new column_1.Column(this, name, new pgJsonb_1.default());
119
126
  }
120
127
  }
121
128
  exports.default = AbstractTable;
@@ -1,8 +1,7 @@
1
1
  import AbstractTable from './abstractTable';
2
2
  export default class MigrationsTable extends AbstractTable<MigrationsTable> {
3
- id: import("../columns/column").IndexedColumn<import("..").PgInteger, true, true>;
4
- version: import("..").Column<import("..").PgInteger, false, false>;
5
- hash: import("..").Column<import("..").PgText, true, false>;
6
- createdAt: import("..").Column<import("..").PgTimestamp, true, false>;
3
+ id: import("..").Column<import("../columns/types/pgSerial").default, true, true>;
4
+ hash: import("..").Column<import("..").PgText, false, false>;
5
+ createdAt: import("..").Column<import("..").PgBigInt, true, true>;
7
6
  tableName(): string;
8
7
  }
@@ -4,13 +4,12 @@ const abstractTable_1 = require("./abstractTable");
4
4
  class MigrationsTable extends abstractTable_1.default {
5
5
  constructor() {
6
6
  super(...arguments);
7
- this.id = this.int('id').autoIncrement().primaryKey();
8
- this.version = this.int('version', { notNull: true }).unique();
9
- this.hash = this.text('hash');
10
- this.createdAt = this.timestamp('created_at');
7
+ this.id = this.serial('id').primaryKey();
8
+ this.hash = this.text('hash').notNull();
9
+ this.createdAt = this.bigint('created_at', 'max_bytes_53');
11
10
  }
12
11
  tableName() {
13
- return 'migrations';
12
+ return 'drizzle_migrations';
14
13
  }
15
14
  }
16
15
  exports.default = MigrationsTable;
package/test.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const _1 = require(".");
3
4
  // import { Pool } from 'pg';
4
5
  // import { DB } from '.';
5
6
  // import { DB, DbConnector } from '.';
@@ -16,11 +17,17 @@ const fromTypeFile = (filepath) => {
16
17
  };
17
18
  (async () => {
18
19
  try {
20
+ const db = await new _1.DbConnector()
21
+ .connectionString('postgresql://postgres@127.0.0.1/drizzle-docs')
22
+ .connect();
23
+ // const serializer = new MigrationSerializer();
24
+ // const res = await serializer.fromDatabase(db);
25
+ // fs.writeFileSync('introspected.json', JSON.stringify(res, null, 2), 'utf8');
19
26
  // const ser = new MigrationSerializer();
20
27
  // const d = db.create(UsersTable) as unknown as AbstractTable<any>;
21
28
  // const f = ser.generate([d], []);
22
29
  // console.log(JSON.stringify(f, null, 2));
23
- // await drizzle.migrator(db).migrate('src/drizzle.config.yaml');
30
+ await _1.drizzle.migrator(db).migrate({ migrationFolder: 'src/drizzle.config.yaml' });
24
31
  // drizzle.migrator(db).migrate({ migrationFolder: '' });
25
32
  // const typesFileNames = fs.readdirSync('/Users/andrewsherman/IdeaProjects/datalayer-orm/src/examples/types');
26
33
  // typesFileNames.forEach((filename) => {
@@ -1,7 +0,0 @@
1
- import AbstractTable from '../../tables/abstractTable';
2
- export default class UsersToUserGroupsTable extends AbstractTable<UsersToUserGroupsTable> {
3
- groupId: import("../../columns/column").Column<import("../..").PgInteger, true, false>;
4
- userId: import("../../columns/column").Column<import("../..").PgInteger, true, false>;
5
- manyToManyIndex: import("../../indexes/tableIndex").default;
6
- tableName(): string;
7
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const column_1 = require("../../columns/column");
4
- const abstractTable_1 = require("../../tables/abstractTable");
5
- const userGroupsTable_1 = require("./userGroupsTable");
6
- const usersTable_1 = require("./usersTable");
7
- class UsersToUserGroupsTable extends abstractTable_1.default {
8
- constructor() {
9
- super(...arguments);
10
- this.groupId = this.int('city_id').foreignKey(userGroupsTable_1.default, (table) => table.id, column_1.OnDelete.CASCADE);
11
- this.userId = this.int('user_id').foreignKey(usersTable_1.default, (table) => table.id, column_1.OnDelete.CASCADE);
12
- this.manyToManyIndex = this.index([this.groupId, this.userId]);
13
- }
14
- tableName() {
15
- return 'users_to_user_groups';
16
- }
17
- }
18
- exports.default = UsersToUserGroupsTable;