-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fdac054
commit 5eaa43c
Showing
6 changed files
with
222 additions
and
115 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
57 changes: 57 additions & 0 deletions
57
plugins/passkey_relay_party/storage/migrations/migrate_20240828.go
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,57 @@ | ||
package migrations | ||
|
||
import ( | ||
"another_node/plugins/passkey_relay_party/storage/model" | ||
|
||
"gorm.io/gorm" | ||
) | ||
|
||
type Migration20240828 struct { | ||
} | ||
|
||
var _ Migration = (*Migration20240828)(nil) | ||
|
||
func (m *Migration20240828) Up(db *gorm.DB) error { | ||
|
||
if !db.Migrator().HasTable(&model.AirAccount{}) { | ||
if err := db.AutoMigrate(&model.AirAccount{}); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
if !db.Migrator().HasTable(&model.AirAccountChain{}) { | ||
if err := db.AutoMigrate(&model.AirAccountChain{}); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
if !db.Migrator().HasTable(&model.Passkey{}) { | ||
if err := db.AutoMigrate(&model.Passkey{}); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (m *Migration20240828) Down(db *gorm.DB) error { | ||
if err := db.Migrator().DropTable( | ||
&model.Passkey{}, | ||
); err != nil { | ||
return err | ||
} | ||
|
||
if err := db.Migrator().DropTable( | ||
&model.AirAccountChain{}, | ||
); err != nil { | ||
return err | ||
} | ||
|
||
if err := db.Migrator().DropTable( | ||
&model.AirAccount{}, | ||
); err != nil { | ||
return err | ||
} | ||
|
||
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,14 @@ | ||
package model | ||
|
||
import "another_node/internal/community/storage" | ||
|
||
type AirAccount struct { | ||
storage.BaseData | ||
Email string `json:"email" gorm:"type:varchar(255)"` | ||
Facebook string `json:"facebook" gorm:"type:varchar(255)"` | ||
Twitter string `json:"twitter" gorm:"type:varchar(255)"` | ||
} | ||
|
||
func (AirAccount) TableName() string { | ||
return "airaccounts" | ||
} |
17 changes: 17 additions & 0 deletions
17
plugins/passkey_relay_party/storage/model/airaccount_chain.go
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,17 @@ | ||
package model | ||
|
||
import "another_node/internal/community/storage" | ||
|
||
type AirAccountChain struct { | ||
storage.BaseData | ||
AirAccountId int64 `json:"airaccount_id" gorm:"column:airaccount_id"` | ||
InitCode string `json:"init_code" gorm:"type:text"` | ||
AA_Address string `json:"aa_address" gorm:"type:varchar(255)"` | ||
EOA_Address string `json:"eoa_address" gorm:"type:varchar(255)"` | ||
Chain string `json:"chain" gorm:"type:varchar(64)"` | ||
WalletVault string `json:"wallet_vault" gorm:"type:text"` | ||
} | ||
|
||
func (AirAccountChain) TableName() string { | ||
return "airaccount_chains" | ||
} |
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,17 @@ | ||
package model | ||
|
||
import "another_node/internal/community/storage" | ||
|
||
type Passkey struct { | ||
storage.BaseData | ||
AirAccountId int64 `json:"airaccount_id" gorm:"column:airaccount_id"` | ||
PasskeyId string `json:"passkey_id" gorm:"type:varchar(128)"` | ||
PasskeyRawId string `json:"passkey_rawid" gorm:"type:varchar(128)"` | ||
PublicKey string `json:"public_key" gorm:"type:varchar(512)"` | ||
Algorithm string `json:"algorithm" gorm:"type:varchar(64)"` | ||
Origin string `json:"origin" gorm:"type:varchar(255)"` | ||
} | ||
|
||
func (Passkey) TableName() string { | ||
return "passkeys" | ||
} |