Skip to content

Commit

Permalink
fix: redo migration file
Browse files Browse the repository at this point in the history
  • Loading branch information
jahzielv committed Nov 6, 2023
1 parent 75d0aa9 commit 8c079fb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
)

func init() {
MigrationClient.AddMigration(Up_20231103135411, Down_20231103135411)
MigrationClient.AddMigration(Up_20231106165200, Down_20231106165200)
}

func Up_20231103135411(tx *sql.Tx) error {
func Up_20231106165200(tx *sql.Tx) error {
stmt := `
ALTER TABLE activities
ADD COLUMN user_email varchar(255) NOT NULL DEFAULT ''
Expand All @@ -20,7 +20,7 @@ func Up_20231103135411(tx *sql.Tx) error {

stmt = `
UPDATE activities t1
INNER JOIN users t2 ON t1.id = t2.id
INNER JOIN users t2 ON t1.user_id = t2.id
SET t1.user_email = t2.email
`

Expand All @@ -31,6 +31,6 @@ func Up_20231103135411(tx *sql.Tx) error {
return nil
}

func Down_20231103135411(tx *sql.Tx) error {
func Down_20231106165200(tx *sql.Tx) error {
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestUp_20231103135411(t *testing.T) {
func TestUp_20231106165200(t *testing.T) {
db := applyUpToPrev(t)

//
Expand All @@ -21,7 +21,7 @@ func TestUp_20231103135411(t *testing.T) {
(1,'2023-11-03 20:32:32','2023-11-03 20:32:32',_binary '$2a$12$n6hwsD7OU2bAXX94551DQOBcNNhfsEPS3Y6JEuLDjsLNvry3lgJjy','0fF81xRQIriYzm5fdXouk3V3tRwsZJhV','admin','admin@email.com',0,'','',0,'admin',0),
(2,'2023-11-03 20:33:13','2023-11-03 20:35:26',_binary '$2a$12$YxPPOd5TOmYhDlH5CfGIfuxBe4GJ78gbwvtxoBHTTw.symxpVcEZS','JPDLcBcv4j1QwIU+rHoRWBt3HVJC8hnf','User 1','user1@email.com',0,'','',0,NULL,0);
INSERT INTO activities VALUES
(1,'2023-11-03 20:32:32',1,'admin','user_logged_in','{"public_ip": "[::1]"}',0),
(1,'2023-11-04 20:32:32',1,'admin','user_logged_in','{"public_ip": "[::1]"}',0),
(2,'2023-11-03 20:32:32',2,'User 1','user_logged_in','{"public_ip": "[::1]"}',0);
`

Expand Down
Loading

0 comments on commit 8c079fb

Please sign in to comment.