-
Notifications
You must be signed in to change notification settings - Fork 8
feat: base code for providerChains and chainMembers #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
osm-vishnukyatannawar
merged 20 commits into
main
from
feat/fallback-provider-migration-and-base-code
Jul 21, 2025
Merged
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
be51d65
chore: migration for fallback provider feature (#437)
kshitij-k-osmosys 892bdf8
feat: configure entities for fallback provider chains (#438)
kshitij-k-osmosys db7ee35
chore: squash and merge changes from branch main
kshitij-k-osmosys c891878
chore: squash and merge branch main
kshitij-k-osmosys 33cebc9
fix: remove unnecessary foreign key for channelType in provider_chains
kshitij-k-osmosys f2c031d
fix: use providerType enums
kshitij-k-osmosys 0c88046
feat: rename column channel_type to provider_type
kshitij-k-osmosys 5be123c
chore: update migration timestamp
kshitij-k-osmosys 790238d
feat: add foreign key FK_PROVIDER_CHAINS_PROVIDER_TYPE
kshitij-k-osmosys 3024888
feat: create provider-chains module and service
kshitij-k-osmosys 2c1dfed
feat: create provider-chain-members module and service
kshitij-k-osmosys 1d47152
chore: export services to enable dependency injection
kshitij-k-osmosys 7d6db08
Merge branch 'main' into feat/fallback-provider-migration-and-base-code
kshitij-k-osmosys ee9b9cc
fix: make description nullable
kshitij-k-osmosys 5652802
style: use camelCase
kshitij-k-osmosys 42f3b7e
refactor: keep provider modules together
kshitij-k-osmosys 25373e9
feat: get first chain member service fn
kshitij-k-osmosys 1a9395b
fix: on delete behavior for FK_PROVIDER_CHAINS_PROVIDER_TYPE
kshitij-k-osmosys 1ffaef7
refactor: remove redundant constant
kshitij-k-osmosys 51eb34c
style: fix constructor parameter name
kshitij-k-osmosys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,8 @@ export const IsEnabledStatus = { | |
FALSE: 0, | ||
TRUE: 1, | ||
}; | ||
|
||
export const IsDefaultStatus = { | ||
FALSE: 0, | ||
TRUE: 1, | ||
}; | ||
354 changes: 354 additions & 0 deletions
354
apps/api/src/database/migrations/1752904253632-FallbackProviderChanges.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,354 @@ | ||
import { | ||
MigrationInterface, | ||
QueryRunner, | ||
Table, | ||
TableColumn, | ||
TableForeignKey, | ||
TableIndex, | ||
TableUnique, | ||
} from 'typeorm'; | ||
|
||
export class FallbackProviderChanges1752904253632 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
// 1. Create notify_provider_chains table | ||
await queryRunner.createTable( | ||
new Table({ | ||
name: 'notify_provider_chains', | ||
columns: [ | ||
{ | ||
name: 'chain_id', | ||
type: 'int', | ||
isPrimary: true, | ||
isGenerated: true, | ||
generationStrategy: 'increment', | ||
}, | ||
{ | ||
name: 'chain_name', | ||
type: 'varchar', | ||
length: '255', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'application_id', | ||
type: 'int', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'provider_type', | ||
type: 'smallint', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'description', | ||
type: 'text', | ||
isNullable: true, | ||
}, | ||
{ | ||
name: 'is_default', | ||
type: 'smallint', | ||
default: '0', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'created_on', | ||
type: 'timestamp', | ||
default: 'CURRENT_TIMESTAMP', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'updated_on', | ||
type: 'timestamp', | ||
default: 'CURRENT_TIMESTAMP', | ||
onUpdate: 'CURRENT_TIMESTAMP', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'status', | ||
type: 'smallint', | ||
default: '1', | ||
isNullable: false, | ||
}, | ||
], | ||
}), | ||
true, | ||
); | ||
|
||
// 2. Create notify_provider_chain_members table | ||
await queryRunner.createTable( | ||
new Table({ | ||
name: 'notify_provider_chain_members', | ||
columns: [ | ||
{ | ||
name: 'id', | ||
type: 'int', | ||
isPrimary: true, | ||
isGenerated: true, | ||
generationStrategy: 'increment', | ||
}, | ||
{ | ||
name: 'chain_id', | ||
type: 'int', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'provider_id', | ||
type: 'int', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'priority_order', | ||
type: 'smallint', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'is_active', | ||
type: 'smallint', | ||
default: '1', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'created_on', | ||
type: 'timestamp', | ||
default: 'CURRENT_TIMESTAMP', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'updated_on', | ||
type: 'timestamp', | ||
default: 'CURRENT_TIMESTAMP', | ||
onUpdate: 'CURRENT_TIMESTAMP', | ||
isNullable: false, | ||
}, | ||
{ | ||
name: 'status', | ||
type: 'smallint', | ||
default: '1', | ||
isNullable: false, | ||
}, | ||
], | ||
}), | ||
true, | ||
); | ||
|
||
// 3. Add Foreign Key Constraints for notify_provider_chains | ||
await queryRunner.createForeignKey( | ||
'notify_provider_chains', | ||
new TableForeignKey({ | ||
columnNames: ['application_id'], | ||
referencedColumnNames: ['application_id'], | ||
referencedTableName: 'notify_applications', | ||
onDelete: 'CASCADE', | ||
name: 'FK_PROVIDER_CHAINS_APPLICATION', | ||
}), | ||
); | ||
|
||
await queryRunner.createForeignKey( | ||
'notify_provider_chains', | ||
new TableForeignKey({ | ||
columnNames: ['provider_type'], | ||
referencedColumnNames: ['provider_type_id'], | ||
referencedTableName: 'notify_provider_types', | ||
onDelete: 'SET NULL', | ||
name: 'FK_PROVIDER_CHAINS_PROVIDER_TYPE', | ||
}), | ||
); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// 4. Add Foreign Key Constraints for notify_provider_chain_members | ||
await queryRunner.createForeignKey( | ||
'notify_provider_chain_members', | ||
new TableForeignKey({ | ||
columnNames: ['chain_id'], | ||
referencedColumnNames: ['chain_id'], | ||
referencedTableName: 'notify_provider_chains', | ||
onDelete: 'CASCADE', | ||
name: 'FK_CHAIN_MEMBERS_CHAIN', | ||
}), | ||
); | ||
|
||
await queryRunner.createForeignKey( | ||
'notify_provider_chain_members', | ||
new TableForeignKey({ | ||
columnNames: ['provider_id'], | ||
referencedColumnNames: ['provider_id'], | ||
referencedTableName: 'notify_providers', | ||
onDelete: 'CASCADE', | ||
name: 'FK_CHAIN_MEMBERS_PROVIDER', | ||
}), | ||
); | ||
|
||
// 5. Create Indexes for notify_provider_chains | ||
await queryRunner.createIndex( | ||
'notify_provider_chains', | ||
new TableIndex({ | ||
columnNames: ['application_id', 'provider_type'], | ||
name: 'IDX_CHAINS_APPLICATION_CHANNEL', | ||
}), | ||
); | ||
|
||
await queryRunner.createIndex( | ||
'notify_provider_chains', | ||
new TableIndex({ | ||
columnNames: ['status'], | ||
name: 'IDX_CHAINS_STATUS', | ||
}), | ||
); | ||
|
||
await queryRunner.createIndex( | ||
'notify_provider_chains', | ||
new TableIndex({ | ||
columnNames: ['application_id', 'provider_type', 'is_default'], | ||
name: 'IDX_CHAINS_DEFAULT', | ||
}), | ||
); | ||
|
||
// 6. Create Indexes for notify_provider_chain_members | ||
await queryRunner.createIndex( | ||
'notify_provider_chain_members', | ||
new TableIndex({ | ||
columnNames: ['chain_id', 'priority_order'], | ||
name: 'IDX_CHAIN_MEMBERS_CHAIN_ORDER', | ||
}), | ||
); | ||
|
||
await queryRunner.createIndex( | ||
'notify_provider_chain_members', | ||
new TableIndex({ | ||
columnNames: ['provider_id'], | ||
name: 'IDX_CHAIN_MEMBERS_PROVIDER', | ||
}), | ||
); | ||
|
||
await queryRunner.createIndex( | ||
'notify_provider_chain_members', | ||
new TableIndex({ | ||
columnNames: ['status'], | ||
name: 'IDX_CHAIN_MEMBERS_STATUS', | ||
}), | ||
); | ||
|
||
// 7. Add Unique Constraints for both tables | ||
await queryRunner.createUniqueConstraint( | ||
'notify_provider_chains', | ||
new TableUnique({ | ||
columnNames: ['application_id', 'chain_name'], | ||
name: 'UQ_APP_CHAIN_NAME', | ||
}), | ||
); | ||
|
||
await queryRunner.createUniqueConstraint( | ||
'notify_provider_chain_members', | ||
new TableUnique({ | ||
columnNames: ['chain_id', 'priority_order'], | ||
name: 'UQ_CHAIN_PRIORITY', | ||
}), | ||
); | ||
|
||
await queryRunner.createUniqueConstraint( | ||
'notify_provider_chain_members', | ||
new TableUnique({ | ||
columnNames: ['chain_id', 'provider_id'], | ||
name: 'UQ_CHAIN_PROVIDER', | ||
}), | ||
); | ||
|
||
// 8. Table modifications for notify_notifications | ||
await queryRunner.addColumn( | ||
'notify_notifications', | ||
new TableColumn({ | ||
name: 'provider_chain_id', | ||
type: 'int', | ||
isNullable: true, | ||
}), | ||
); | ||
|
||
await queryRunner.createForeignKey( | ||
'notify_notifications', | ||
new TableForeignKey({ | ||
columnNames: ['provider_chain_id'], | ||
referencedColumnNames: ['chain_id'], | ||
referencedTableName: 'notify_provider_chains', | ||
onDelete: 'SET NULL', | ||
name: 'FK_NOTIFICATIONS_PROVIDER_CHAIN', | ||
}), | ||
); | ||
|
||
await queryRunner.createIndex( | ||
'notify_notifications', | ||
new TableIndex({ | ||
columnNames: ['provider_chain_id'], | ||
name: 'IDX_NOTIFICATIONS_PROVIDER_CHAIN', | ||
}), | ||
); | ||
|
||
// 9. Table modifications for notify_archived_notifications | ||
await queryRunner.addColumn( | ||
'notify_archived_notifications', | ||
new TableColumn({ | ||
name: 'provider_chain_id', | ||
type: 'int', | ||
isNullable: true, | ||
}), | ||
); | ||
|
||
await queryRunner.createForeignKey( | ||
'notify_archived_notifications', | ||
new TableForeignKey({ | ||
columnNames: ['provider_chain_id'], | ||
referencedColumnNames: ['chain_id'], | ||
referencedTableName: 'notify_provider_chains', | ||
onDelete: 'SET NULL', | ||
name: 'FK_ARCHIVED_NOTIFICATIONS_PROVIDER_CHAIN', | ||
}), | ||
); | ||
|
||
await queryRunner.createIndex( | ||
'notify_archived_notifications', | ||
new TableIndex({ | ||
columnNames: ['provider_chain_id'], | ||
name: 'IDX_ARCHIVED_NOTIFICATIONS_PROVIDER_CHAIN', | ||
}), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
// 1. Revert changes from table notify_archived_notifications | ||
await queryRunner.dropIndex( | ||
'notify_archived_notifications', | ||
'IDX_ARCHIVED_NOTIFICATIONS_PROVIDER_CHAIN', | ||
); | ||
await queryRunner.dropForeignKey( | ||
'notify_archived_notifications', | ||
'FK_ARCHIVED_NOTIFICATIONS_PROVIDER_CHAIN', | ||
); | ||
await queryRunner.dropColumn('notify_archived_notifications', 'provider_chain_id'); | ||
|
||
// 2. Revert changes from table notify_notifications | ||
await queryRunner.dropIndex('notify_notifications', 'IDX_NOTIFICATIONS_PROVIDER_CHAIN'); | ||
await queryRunner.dropForeignKey('notify_notifications', 'FK_NOTIFICATIONS_PROVIDER_CHAIN'); | ||
await queryRunner.dropColumn('notify_notifications', 'provider_chain_id'); | ||
|
||
// 3. Drop Unique Constraints | ||
await queryRunner.dropUniqueConstraint('notify_provider_chain_members', 'UQ_CHAIN_PROVIDER'); | ||
await queryRunner.dropUniqueConstraint('notify_provider_chain_members', 'UQ_CHAIN_PRIORITY'); | ||
await queryRunner.dropUniqueConstraint('notify_provider_chains', 'UQ_APP_CHAIN_NAME'); | ||
|
||
// 4. Drop Indexes | ||
await queryRunner.dropIndex('notify_provider_chain_members', 'IDX_CHAIN_MEMBERS_STATUS'); | ||
await queryRunner.dropIndex('notify_provider_chain_members', 'IDX_CHAIN_MEMBERS_PROVIDER'); | ||
await queryRunner.dropIndex('notify_provider_chain_members', 'IDX_CHAIN_MEMBERS_CHAIN_ORDER'); | ||
|
||
await queryRunner.dropIndex('notify_provider_chains', 'IDX_CHAINS_DEFAULT'); | ||
await queryRunner.dropIndex('notify_provider_chains', 'IDX_CHAINS_STATUS'); | ||
await queryRunner.dropIndex('notify_provider_chains', 'IDX_CHAINS_APPLICATION_CHANNEL'); | ||
|
||
// 5. Drop Foreign Key Constraints | ||
await queryRunner.dropForeignKey('notify_provider_chain_members', 'FK_CHAIN_MEMBERS_PROVIDER'); | ||
await queryRunner.dropForeignKey('notify_provider_chain_members', 'FK_CHAIN_MEMBERS_CHAIN'); | ||
await queryRunner.dropForeignKey('notify_provider_chains', 'FK_PROVIDER_CHAINS_PROVIDER_TYPE'); | ||
await queryRunner.dropForeignKey('notify_provider_chains', 'FK_PROVIDER_CHAINS_APPLICATION'); | ||
|
||
// 6. Drop tables in reverse order of creation to respect dependencies | ||
await queryRunner.dropTable('notify_provider_chain_members'); | ||
await queryRunner.dropTable('notify_provider_chains'); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.