|
1 | 1 | const { DataTypes } = require('sequelize'); |
| 2 | +const { sequelize } = require('../database/connection'); |
2 | 3 |
|
3 | | -module.exports = (sequelize) => { |
4 | | - const GrantStream = sequelize.define('GrantStream', { |
5 | | - id: { |
6 | | - type: DataTypes.INTEGER, |
7 | | - primaryKey: true, |
8 | | - autoIncrement: true, |
9 | | - }, |
10 | | - address: { |
11 | | - type: DataTypes.STRING(42), |
12 | | - allowNull: false, |
13 | | - unique: true, |
14 | | - comment: 'Contract address of the grant stream', |
15 | | - }, |
16 | | - name: { |
17 | | - type: DataTypes.STRING(255), |
18 | | - allowNull: false, |
19 | | - comment: 'Human-readable name of the grant project', |
20 | | - }, |
21 | | - description: { |
22 | | - type: DataTypes.TEXT, |
23 | | - comment: 'Detailed description of the grant project', |
24 | | - }, |
25 | | - owner_address: { |
26 | | - type: DataTypes.STRING(42), |
27 | | - allowNull: false, |
28 | | - comment: 'Address of the grant project owner', |
29 | | - }, |
30 | | - token_address: { |
31 | | - type: DataTypes.STRING(42), |
32 | | - allowNull: false, |
33 | | - comment: 'Token address used for funding', |
34 | | - }, |
35 | | - target_amount: { |
36 | | - type: DataTypes.DECIMAL(20, 8), |
37 | | - defaultValue: 0, |
38 | | - comment: 'Target funding amount for the grant', |
39 | | - }, |
40 | | - current_amount: { |
41 | | - type: DataTypes.DECIMAL(20, 8), |
42 | | - defaultValue: 0, |
43 | | - comment: 'Current amount funded to the grant', |
44 | | - }, |
45 | | - is_active: { |
46 | | - type: DataTypes.BOOLEAN, |
47 | | - defaultValue: true, |
48 | | - comment: 'Whether the grant stream is currently active', |
49 | | - }, |
50 | | - start_date: { |
51 | | - type: DataTypes.DATE, |
52 | | - defaultValue: DataTypes.NOW, |
53 | | - comment: 'When the grant stream starts accepting funds', |
54 | | - }, |
55 | | - end_date: { |
56 | | - type: DataTypes.DATE, |
57 | | - comment: 'When the grant stream stops accepting funds', |
58 | | - }, |
59 | | - metadata: { |
60 | | - type: DataTypes.JSONB, |
61 | | - defaultValue: {}, |
62 | | - comment: 'Additional project metadata', |
63 | | - }, |
64 | | - }, { |
65 | | - tableName: 'grant_streams', |
66 | | - timestamps: true, |
67 | | - createdAt: 'created_at', |
68 | | - updatedAt: 'updated_at', |
69 | | - indexes: [ |
70 | | - { fields: ['address'] }, |
71 | | - { fields: ['is_active'] }, |
72 | | - { fields: ['owner_address'] }, |
73 | | - ], |
74 | | - }); |
| 4 | +const GrantStream = sequelize.define('GrantStream', { |
| 5 | + id: { |
| 6 | + type: DataTypes.INTEGER, |
| 7 | + primaryKey: true, |
| 8 | + autoIncrement: true, |
| 9 | + }, |
| 10 | + address: { |
| 11 | + type: DataTypes.STRING(42), |
| 12 | + allowNull: false, |
| 13 | + unique: true, |
| 14 | + comment: 'Contract address of the grant stream', |
| 15 | + }, |
| 16 | + name: { |
| 17 | + type: DataTypes.STRING(255), |
| 18 | + allowNull: false, |
| 19 | + comment: 'Human-readable name of the grant project', |
| 20 | + }, |
| 21 | + description: { |
| 22 | + type: DataTypes.TEXT, |
| 23 | + comment: 'Detailed description of the grant project', |
| 24 | + }, |
| 25 | + owner_address: { |
| 26 | + type: DataTypes.STRING(42), |
| 27 | + allowNull: false, |
| 28 | + comment: 'Address of the grant project owner', |
| 29 | + }, |
| 30 | + token_address: { |
| 31 | + type: DataTypes.STRING(42), |
| 32 | + allowNull: false, |
| 33 | + comment: 'Token address used for funding', |
| 34 | + }, |
| 35 | + target_amount: { |
| 36 | + type: DataTypes.DECIMAL(20, 8), |
| 37 | + defaultValue: 0, |
| 38 | + comment: 'Target funding amount for the grant', |
| 39 | + }, |
| 40 | + current_amount: { |
| 41 | + type: DataTypes.DECIMAL(20, 8), |
| 42 | + defaultValue: 0, |
| 43 | + comment: 'Current amount funded to the grant', |
| 44 | + }, |
| 45 | + is_active: { |
| 46 | + type: DataTypes.BOOLEAN, |
| 47 | + defaultValue: true, |
| 48 | + comment: 'Whether the grant stream is currently active', |
| 49 | + }, |
| 50 | + start_date: { |
| 51 | + type: DataTypes.DATE, |
| 52 | + defaultValue: DataTypes.NOW, |
| 53 | + comment: 'When the grant stream starts accepting funds', |
| 54 | + }, |
| 55 | + end_date: { |
| 56 | + type: DataTypes.DATE, |
| 57 | + comment: 'When the grant stream stops accepting funds', |
| 58 | + }, |
| 59 | + metadata: { |
| 60 | + type: DataTypes.JSONB, |
| 61 | + defaultValue: {}, |
| 62 | + comment: 'Additional project metadata', |
| 63 | + }, |
| 64 | + backup_wallet: { |
| 65 | + type: DataTypes.STRING(56), |
| 66 | + allowNull: true, |
| 67 | + comment: 'Nominated backup wallet for succession', |
| 68 | + }, |
| 69 | + last_active_at: { |
| 70 | + type: DataTypes.DATE, |
| 71 | + defaultValue: DataTypes.NOW, |
| 72 | + comment: 'Timestamp of the last action by the primary wallet', |
| 73 | + }, |
| 74 | +}, { |
| 75 | + tableName: 'grant_streams', |
| 76 | + timestamps: true, |
| 77 | + createdAt: 'created_at', |
| 78 | + updatedAt: 'updated_at', |
| 79 | + indexes: [ |
| 80 | + { fields: ['address'] }, |
| 81 | + { fields: ['is_active'] }, |
| 82 | + { fields: ['owner_address'] }, |
| 83 | + ], |
| 84 | +}); |
75 | 85 |
|
76 | | - return GrantStream; |
77 | | -}; |
| 86 | +module.exports = GrantStream; |
0 commit comments