202506170342_swaps.go raw
1 package migrations
2
3 import (
4 _ "embed"
5 "text/template"
6
7 "github.com/go-gormigrate/gormigrate/v2"
8 "gorm.io/gorm"
9 )
10
11 const swapsMigration = `
12 CREATE TABLE swaps(
13 id {{ .AutoincrementPrimaryKey }},
14 swap_id text UNIQUE,
15 type text,
16 state text,
17 invoice text,
18 send_amount integer,
19 receive_amount integer,
20 destination_address text,
21 refund_address text,
22 lockup_address text,
23 boltz_pubkey text,
24 preimage text,
25 payment_hash text,
26 lockup_tx_id text,
27 claim_tx_id text,
28 auto_swap boolean,
29 timeout_block_height integer,
30 swap_tree json,
31 created_at {{ .Timestamp }},
32 updated_at {{ .Timestamp }}
33 );
34 `
35
36 var swapsMigrationTmpl = template.Must(template.New("swapsMigration").Parse(swapsMigration))
37
38 var _202506170342_swaps = &gormigrate.Migration{
39 ID: "202506170342_swaps",
40 Migrate: func(tx *gorm.DB) error {
41
42 if err := exec(tx, swapsMigrationTmpl); err != nil {
43 return err
44 }
45
46 return nil
47 },
48 Rollback: func(tx *gorm.DB) error {
49 return nil
50 },
51 }
52