-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ronin-chain/chore/cleanup
chore: add migrations code and adapt `cleanup` branch from bridge-core
- Loading branch information
Showing
30 changed files
with
452 additions
and
1,324 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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,23 @@ | ||
package models | ||
|
||
import ( | ||
"gorm.io/gorm" | ||
) | ||
|
||
type Deposit struct { | ||
ID int `json:"id" gorm:"primary_key:true;column:id;auto_increment;not null"` | ||
Owner string `json:"owner" gorm:"column:owner;index:idx_deposit_owner;not null"` | ||
TokenAddress string `json:"tokenAddress" gorm:"column:token_address;index:idx_deposit_token_address;not null"` | ||
TokenNumber int `json:"tokenNumber" gorm:"column:token_number;not null"` | ||
BlockNumber int64 `json:"blockNumber" gorm:"column:block_number;index:idx_deposit_block_number;not null"` | ||
SidechainToken string `json:"sidechainToken" gorm:"column:sidechain_token;not null"` | ||
Standard int `json:"standard" gorm:"column:standard;not null"` | ||
} | ||
|
||
func (m Deposit) BeforeCreate(tx *gorm.DB) (err error) { | ||
return nil | ||
} | ||
|
||
func (m Deposit) TableName() string { | ||
return "deposit" | ||
} |
This file contains 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,19 @@ | ||
package models | ||
|
||
import "gorm.io/gorm" | ||
|
||
type Event struct { | ||
ID int `json:"id" gorm:"primary_key:true;column:id;auto_increment;not null"` | ||
EventName string `json:"eventName" gorm:"column:event_name;uniqueIndex:idx_event_event_name_tx;not null"` | ||
TransactionHash string `json:"transactionHash" gorm:"column:transaction_hash;uniqueIndex:idx_event_event_name_tx;not null"` | ||
FromChainId string `json:"fromChainId" gorm:"column:from_chain_id;not null"` | ||
CreatedAt int64 `json:"created_at" gorm:"column:created_at;type:bigint;index:idx_event_created_at;not null"` | ||
} | ||
|
||
func (e Event) BeforeCreate(tx *gorm.DB) (err error) { | ||
return nil | ||
} | ||
|
||
func (e Event) TableName() string { | ||
return "event" | ||
} |
This file contains 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,29 @@ | ||
package models | ||
|
||
import ( | ||
"gorm.io/gorm" | ||
) | ||
|
||
type Job struct { | ||
ID int `json:"id" gorm:"primary_key:true;column:id;auto_increment;not null"` | ||
Listener string `json:"listener" gorm:"column:listener;index:idx_job_listener_name;not null"` | ||
SubscriptionName string `json:"subscriptionName" gorm:"column:subscription_name;not null"` | ||
Type int `json:"type" gorm:"column:type;not null"` | ||
RetryCount int `json:"retryCount" gorm:"column:retry_count;not null"` | ||
Status string `json:"status" gorm:"column:status;not null"` | ||
Data string `json:"data" gorm:"column:data;not null"` | ||
Transaction string `json:"transaction" gorm:"column:transaction;index:idx_job_transaction;not null"` | ||
CreatedAt int64 `json:"created_at" gorm:"column:created_at;type:bigint;index:idx_job_created_at;not null"` | ||
FromChainId string `json:"fromChainId" gorm:"column:from_chain_id;not null"` | ||
|
||
// Method is used to execute function in `callback` job | ||
Method string `json:"method" gorm:"column:method;not null"` | ||
} | ||
|
||
func (m Job) BeforeCreate(tx *gorm.DB) (err error) { | ||
return nil | ||
} | ||
|
||
func (m Job) TableName() string { | ||
return "job" | ||
} |
This file contains 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,18 @@ | ||
package models | ||
|
||
import ( | ||
"github.com/go-gormigrate/gormigrate/v2" | ||
"gorm.io/gorm" | ||
) | ||
|
||
func Migrate() *gormigrate.Migration { | ||
return &gormigrate.Migration{ | ||
ID: "20220515", | ||
Migrate: func(tx *gorm.DB) error { | ||
return tx.AutoMigrate(&Deposit{}, &Event{}, &Job{}, &ProcessedBlock{}, &Task{}, &Withdrawal{}) | ||
}, | ||
Rollback: func(tx *gorm.DB) error { | ||
return nil | ||
}, | ||
} | ||
} |
This file contains 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,19 @@ | ||
package models | ||
|
||
import ( | ||
"gorm.io/gorm" | ||
) | ||
|
||
type ProcessedBlock struct { | ||
ID int `json:"id" gorm:"primary_key:true;column:id;auto_increment;not null"` | ||
ChainId string `json:"chainId" gorm:"column:chain_id;not null"` | ||
Block int64 `json:"block" gorm:"column:block;not null"` | ||
} | ||
|
||
func (m ProcessedBlock) BeforeCreate(tx *gorm.DB) (err error) { | ||
return nil | ||
} | ||
|
||
func (m ProcessedBlock) TableName() string { | ||
return "processed_block" | ||
} |
This file contains 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,28 @@ | ||
package models | ||
|
||
import ( | ||
"gorm.io/gorm" | ||
) | ||
|
||
type Task struct { | ||
ID int `json:"id" gorm:"primary_key:true;column:id;auto_increment;not null"` | ||
ChainId string `json:"chainId" gorm:"column:chain_id;index:idx_job_chain_id;not null"` | ||
FromChainId string `json:"fromChainId" gorm:"column:from_chain_id;not null"` | ||
Type string `json:"type" gorm:"column:task_type;not null"` | ||
Data string `json:"data" gorm:"column:data;not null"` | ||
Retries int `json:"retries" gorm:"column:retries;not null"` | ||
Status string `json:"status" gorm:"column:status;not null"` | ||
LastError string `json:"lastError" gorm:"column:last_error"` | ||
TransactionHash string `json:"transactionHash" gorm:"transaction_hash;index:idx_task_transaction_hash;not null"` | ||
FromTransaction string `json:"fromTransaction" gorm:"from_transaction;index:idx_task_from_transaction;not null"` | ||
TransactionStatus int `json:"transactionStatus" gorm:"transaction_status;index:idx_task_transaction_status;not null"` | ||
CreatedAt int64 `json:"createdAt" gorm:"column:created_at;type:bigint;index:idx_task_created_at;not null"` | ||
} | ||
|
||
func (m Task) BeforeCreate(tx *gorm.DB) (err error) { | ||
return nil | ||
} | ||
|
||
func (m Task) TableName() string { | ||
return "task" | ||
} |
Oops, something went wrong.