-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetadata-column.ts
More file actions
71 lines (68 loc) · 1.49 KB
/
metadata-column.ts
File metadata and controls
71 lines (68 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../config/database';
import MetadataTable from './metadata-table';
class MetadataColumn extends Model {
public id!: string;
public table_id!: string;
public column_name!: string;
public data_type!: string;
public is_primary!: boolean;
public is_nullable!: boolean;
public is_unique!: boolean;
public readonly createdAt!: Date;
public readonly updatedAt!: Date;
}
MetadataColumn.init(
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
table_id: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: MetadataTable,
key: 'id',
},
onDelete: 'CASCADE',
},
column_name: {
type: DataTypes.STRING,
allowNull: false,
},
data_type: {
type: DataTypes.STRING,
allowNull: false,
},
is_primary: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
is_nullable: {
type: DataTypes.BOOLEAN,
defaultValue: true,
},
is_unique: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
created_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
},
updated_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
},
},
{
sequelize,
modelName: 'MetadataColumn',
tableName: 'metadata_column',
timestamps: true,
underscored: true,
},
);
export default MetadataColumn;