dialect/sql/schema: change id type of ent_types table to be unsigned (#612)

This commit is contained in:
Ariel Mashraki
2020-07-16 20:07:37 +03:00
committed by GitHub
parent 4e9fd67a3e
commit 33e4eb3a52
2 changed files with 2 additions and 2 deletions

View File

@@ -439,7 +439,7 @@ func (m *Migrate) types(ctx context.Context, tx dialect.Tx) error {
}
if !exists {
t := NewTable(TypeTable).
AddPrimary(&Column{Name: "id", Type: field.TypeInt, Increment: true}).
AddPrimary(&Column{Name: "id", Type: field.TypeUint, Increment: true}).
AddColumn(&Column{Name: "type", Type: field.TypeString, Unique: true})
query, args := m.tBuilder(t).Query()
if err := tx.Exec(ctx, query, args, nil); err != nil {

View File

@@ -853,7 +853,7 @@ func TestMySQL_Create(t *testing.T) {
mock.start("5.7.23")
mock.tableExists("ent_types", false)
// create ent_types table.
mock.ExpectExec(escape("CREATE TABLE IF NOT EXISTS `ent_types`(`id` bigint AUTO_INCREMENT NOT NULL, `type` varchar(255) UNIQUE NOT NULL, PRIMARY KEY(`id`)) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin")).
mock.ExpectExec(escape("CREATE TABLE IF NOT EXISTS `ent_types`(`id` bigint unsigned AUTO_INCREMENT NOT NULL, `type` varchar(255) UNIQUE NOT NULL, PRIMARY KEY(`id`)) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin")).
WillReturnResult(sqlmock.NewResult(0, 1))
mock.tableExists("users", false)
mock.ExpectExec(escape("CREATE TABLE IF NOT EXISTS `users`(`id` bigint AUTO_INCREMENT NOT NULL, PRIMARY KEY(`id`)) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin")).