From d6a708fc55a8fe079c70cd2567311e3bed22c245 Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Sun, 19 Jan 2020 15:54:17 +0800 Subject: [PATCH] update vendor --- go.mod | 2 +- go.sum | 4 ++-- vendor/modules.txt | 2 +- vendor/yunion.io/x/sqlchemy/sync.go | 16 ++++++++++++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 406557b04a..b2b5ad0aa0 100644 --- a/go.mod +++ b/go.mod @@ -139,7 +139,7 @@ require ( yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d yunion.io/x/pkg v0.0.0-20200103043034-27c6f82160fa yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e - yunion.io/x/sqlchemy v0.0.0-20200114051901-dfdc01cac3c3 + yunion.io/x/sqlchemy v0.0.0-20200119074814-09089d67c78d yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3 ) diff --git a/go.sum b/go.sum index e93ee1fc4f..c0cc9718a6 100644 --- a/go.sum +++ b/go.sum @@ -679,7 +679,7 @@ yunion.io/x/pkg v0.0.0-20200103043034-27c6f82160fa h1:+7zYi8MhaOW/53/7FOERnhQqAU yunion.io/x/pkg v0.0.0-20200103043034-27c6f82160fa/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e h1:v+EzIadodSwkdZ/7bremd7J8J50Cise/HCylsOJngmo= yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo= -yunion.io/x/sqlchemy v0.0.0-20200114051901-dfdc01cac3c3 h1:4OA/7udM060GPhj1hqX80Tu+lC2ziAcMrKpo+EG5LZA= -yunion.io/x/sqlchemy v0.0.0-20200114051901-dfdc01cac3c3/go.mod h1:FTdwPdGhMgh4E+UFXc9klI1Ok34fMuybTT+jLhOaIjI= +yunion.io/x/sqlchemy v0.0.0-20200119074814-09089d67c78d h1:z9gliVPaZir4qJ9/E1ItnqCZeMq1thGbcuRwYeSKgQM= +yunion.io/x/sqlchemy v0.0.0-20200119074814-09089d67c78d/go.mod h1:FTdwPdGhMgh4E+UFXc9klI1Ok34fMuybTT+jLhOaIjI= yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3 h1:bfC8EhXYvyGYldRWlzxiCM39Zfj3s3+zham9mW2h2LE= yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3/go.mod h1:EP6NSv2C0zzqBDTKumv8hPWLb3XvgMZDHQRfyuOrQng= diff --git a/vendor/modules.txt b/vendor/modules.txt index 3d3c7ce153..ee260936b7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -846,7 +846,7 @@ yunion.io/x/pkg/util/workqueue yunion.io/x/pkg/utils # yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e yunion.io/x/s3cli -# yunion.io/x/sqlchemy v0.0.0-20200114051901-dfdc01cac3c3 +# yunion.io/x/sqlchemy v0.0.0-20200119074814-09089d67c78d yunion.io/x/sqlchemy # yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3 yunion.io/x/structarg diff --git a/vendor/yunion.io/x/sqlchemy/sync.go b/vendor/yunion.io/x/sqlchemy/sync.go index 4fa1ab1e15..5c6b864c4e 100644 --- a/vendor/yunion.io/x/sqlchemy/sync.go +++ b/vendor/yunion.io/x/sqlchemy/sync.go @@ -335,9 +335,22 @@ func (ts *STableSpec) SyncSQL() []string { /* IGNORE DROP STATEMENT */ for _, col := range remove { sql := fmt.Sprintf("DROP COLUMN `%s`", col.Name()) + log.Infof("ALTER TABLE %s %s;", ts.name, sql) // alters = append(alters, sql) // ignore drop statement - // but if the column is not nullable but no default + // if the column is auto_increment integer column, + // then need to drop auto_increment attribute + if intCol, ok := col.(*SIntegerColumn); ok { + if intCol.IsAutoIncrement { + // make sure the column is nullable + col.SetNullable(true) + log.Errorf("column %s is auto_increment, drop auto_inrement attribute", col.Name()) + intCol.IsAutoIncrement = false + sql := fmt.Sprintf("MODIFY %s", col.DefinitionString()) + alters = append(alters, sql) + } + } + // if the column is not nullable but no default // then need to drop the not-nullable attribute if !col.IsNullable() && col.Default() == "" { col.SetNullable(true) @@ -345,7 +358,6 @@ func (ts *STableSpec) SyncSQL() []string { alters = append(alters, sql) log.Errorf("column %s is not nullable but no default, drop not nullable attribute", col.Name()) } - log.Infof("ALTER TABLE %s %s;", ts.name, sql) } for _, cols := range update { sql := fmt.Sprintf("MODIFY %s", cols.newCol.DefinitionString())