File tree Expand file tree Collapse file tree 3 files changed +107
-0
lines changed
Expand file tree Collapse file tree 3 files changed +107
-0
lines changed Original file line number Diff line number Diff line change 1+ import { DataTypes } from "sequelize" ;
2+ import { Migration } from "../umzug" ;
3+
4+ const TABLE_NAME = "files" ;
5+
6+ export const up : Migration = async ( { context : sequelize } ) => {
7+ await sequelize . getQueryInterface ( ) . createTable ( TABLE_NAME , {
8+ id : {
9+ type : DataTypes . UUID ,
10+ defaultValue : DataTypes . UUIDV4 ,
11+ allowNull : false ,
12+ primaryKey : true ,
13+ } ,
14+ storagePath : {
15+ type : DataTypes . STRING ,
16+ allowNull : false ,
17+ } ,
18+ originalFileName : {
19+ type : DataTypes . STRING ,
20+ allowNull : false ,
21+ } ,
22+ uploadedUserId : {
23+ type : DataTypes . INTEGER ,
24+ allowNull : false ,
25+ references : {
26+ model : "users" ,
27+ key : "id" ,
28+ } ,
29+ } ,
30+ sizeBytes : {
31+ type : DataTypes . BIGINT ,
32+ allowNull : false ,
33+ } ,
34+ createdAt : {
35+ type : DataTypes . DATE ,
36+ allowNull : false ,
37+ defaultValue : DataTypes . NOW ,
38+ } ,
39+ updatedAt : {
40+ type : DataTypes . DATE ,
41+ allowNull : false ,
42+ defaultValue : DataTypes . NOW ,
43+ } ,
44+ } ) ;
45+ } ;
46+
47+ export const down : Migration = async ( { context : sequelize } ) => {
48+ await sequelize . getQueryInterface ( ) . dropTable ( TABLE_NAME ) ;
49+ } ;
Original file line number Diff line number Diff line change 1+ import {
2+ Column ,
3+ DataType ,
4+ ForeignKey ,
5+ Model ,
6+ Table ,
7+ } from "sequelize-typescript" ;
8+ import User from "./user.model" ;
9+
10+ @Table ( { tableName : "files" } )
11+ export default class File extends Model {
12+ @Column ( {
13+ type : DataType . UUID ,
14+ defaultValue : DataType . UUIDV4 ,
15+ primaryKey : true ,
16+ } )
17+ id ! : string ;
18+
19+ @Column ( { type : DataType . STRING , allowNull : false } )
20+ storagePath ! : string ;
21+
22+ @Column ( {
23+ type : DataType . STRING ,
24+ allowNull : false ,
25+ } )
26+ originalFileName ! : string ;
27+
28+ @ForeignKey ( ( ) => User )
29+ @Column ( {
30+ type : DataType . INTEGER ,
31+ allowNull : false ,
32+ } )
33+ uploadedUserId ! : number ;
34+
35+ @Column ( { type : DataType . BIGINT , allowNull : false } )
36+ sizeBytes ! : bigint ;
37+
38+ @Column ( { type : DataType . DATE , allowNull : false } )
39+ createdAt ! : Date ;
40+
41+ @Column ( { type : DataType . DATE , allowNull : false } )
42+ updatedAt ! : Date ;
43+ }
Original file line number Diff line number Diff line change @@ -259,3 +259,18 @@ export type CreateAdminCommentDTO = Pick<
259259 AdminCommentDTO ,
260260 "userId" | "applicantRecordId" | "comment"
261261> ;
262+
263+ export type FirebaseFileDTO = {
264+ id : string ;
265+ storagePath : string ;
266+ originalFileName : string ;
267+ uploadedUserId : number ;
268+ sizeBytes : bigint ;
269+ createdAt : Date ;
270+ updatedAt : Date ;
271+ } ;
272+
273+ export type CreateFirebaseFileDTO = Omit <
274+ FirebaseFileDTO ,
275+ "id" | "createdAt" | "updatedAt"
276+ > ;
You can’t perform that action at this time.
0 commit comments