-
-
Notifications
You must be signed in to change notification settings - Fork 799
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
Showing
3 changed files
with
56 additions
and
2 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
42 changes: 42 additions & 0 deletions
42
db/migrations/20200819111809_drop_email_unique_constraint.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,42 @@ | ||
package migrations | ||
|
||
import ( | ||
"database/sql" | ||
|
||
"github.com/pressly/goose" | ||
) | ||
|
||
func init() { | ||
goose.AddMigration(upDropEmailUniqueConstraint, downDropEmailUniqueConstraint) | ||
} | ||
|
||
func upDropEmailUniqueConstraint(tx *sql.Tx) error { | ||
_, err := tx.Exec(` | ||
create table user_dg_tmp | ||
( | ||
id varchar(255) not null | ||
primary key, | ||
user_name varchar(255) default '' not null | ||
unique, | ||
name varchar(255) default '' not null, | ||
email varchar(255) default '' not null, | ||
password varchar(255) default '' not null, | ||
is_admin bool default FALSE not null, | ||
last_login_at datetime, | ||
last_access_at datetime, | ||
created_at datetime not null, | ||
updated_at datetime not null | ||
); | ||
insert into user_dg_tmp(id, user_name, name, email, password, is_admin, last_login_at, last_access_at, created_at, updated_at) select id, user_name, name, email, password, is_admin, last_login_at, last_access_at, created_at, updated_at from user; | ||
drop table user; | ||
alter table user_dg_tmp rename to user; | ||
`) | ||
return err | ||
} | ||
|
||
func downDropEmailUniqueConstraint(tx *sql.Tx) 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