美文网首页golang
gorm 插入新的字段

gorm 插入新的字段

作者: 顶尖少爷 | 来源:发表于2020-06-12 15:50 被阅读0次

插入字段 和 创建索引

c :=0
sql =`select count(1) as  c from information_schema.columns where  table_name = '`+tableName+`' and column_name = 'os_type'`
row :=fun.GameDb.Raw(sql).Row()
row.Scan(&c)
if c==0{
    sql :=`alter table `+tableName+` add  column os_type varchar(12) default '' comment '系统ios/andirod'`
    fmt.Println(sql)
    fun.GameDb.Exec(sql)
    sql = `alter table `+tableName+` add  index in_os_type(os_type) `
    fun.GameDb.Exec(sql)
    }

相关文章

网友评论

    本文标题:gorm 插入新的字段

    本文链接:https://www.haomeiwen.com/subject/kexntktx.html