From 1fdc66710e71692e188d00a26f2fc84ba40c5c10 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 14 Jun 2020 19:13:16 +0800 Subject: [PATCH] Add table options --- migrator/migrator.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/migrator/migrator.go b/migrator/migrator.go index a98f7fe3..6baa9dc3 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -203,6 +203,11 @@ func (m Migrator) CreateTable(values ...interface{}) error { createTableSQL = strings.TrimSuffix(createTableSQL, ",") createTableSQL += ")" + + if tableOption, ok := m.DB.Get("gorm:table_options"); ok { + createTableSQL += fmt.Sprint(tableOption) + } + return tx.Exec(createTableSQL, values...).Error }); err != nil { return err