go xorm reverse sqlite3 有误 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
请不要在回答技术问题时复制粘贴 AI 生成的内容
SpiderShrimp

go xorm reverse sqlite3 有误

  •  
  •   SpiderShrimp Oct 23, 2019 1771 views
    This topic created in 2381 days ago, the information mentioned may be changed or developed.

    我要将数据库从 sqlite3 自动迁移到 mysql,因为二者关键字有些细微的差别,这也是我为什么不用 dump 文件的原因。所以我打算用 xorm 工具读取 sqlite3 数据库生成映射结构体,然后用结构体在代码里同步表结构和数据到 mysql 去。 但是生成的时候居然生成出错误的结构体,我没有 NOT 这个字段的,给我生成出来了,我去掉表字段的 not null 约束后恢复正常,但是怎样保证没去掉的时候也是正常的。 type _usersOld20191023 struct { Id string xorm:"varchar(32)" Not string xorm:"not null NULL" PrivateKey string xorm:"varchar(100)" Not string xorm:"not null NULL" PublicKey string xorm:"varchar(100)" Not string xorm:"not null NULL" PrivateIpId string xorm:"varchar(32)" Not string xorm:"not null NULL" CreateTime int64 xorm:"not null bigint" }

    type Boxes struct { Id string xorm:"varchar(32)" Not string xorm:"not null NULL" PrivateKey string xorm:"varchar(100)" Not string xorm:"not null NULL" PublicKey string xorm:"varchar(100)" Not string xorm:"not null NULL" AllowIps string xorm:"varchar(200)" Not string xorm:"not null NULL" PrivateIpId string xorm:"varchar(100)" Not string xorm:"not null NULL" CreateTime int64 xorm:"not null bigint" }

    7 replies    2019-10-24 15:58:03 +08:00
    SpiderShrimp
        1
    SpiderShrimp  
    OP
       Oct 23, 2019
    type _usersOld20191023 struct {
    Id string `xorm:"varchar(32)"`
    Not string `xorm:"not null NULL"`
    PrivateKey string `xorm:"varchar(100)"`
    Not string `xorm:"not null NULL"`
    PublicKey string `xorm:"varchar(100)"`
    Not string `xorm:"not null NULL"`
    PrivateIpId string `xorm:"varchar(32)"`
    Not string `xorm:"not null NULL"`
    CreateTime int64 `xorm:"not null bigint"`
    }
    SpiderShrimp
        2
    SpiderShrimp  
    OP
       Oct 23, 2019
    小白不太会编辑,后面的代码可以无视,只看上面这个就好了。
    zunceng
        3
    zunceng  
       Oct 23, 2019
    xorm reverse 这个工具做的 。。。一言难尽
    记得 postgres 用 xorm,schema 不能选 还需要魔改 reverse 代码才行
    zunceng
        4
    zunceng  
       Oct 23, 2019
    就 mysql 是好用的 其他数据库 步步为营吧
    reus
        5
    reus  
       Oct 23, 2019
    bug 多的包就不要用了
    SpiderShrimp
        6
    SpiderShrimp  
    OP
       Oct 24, 2019
    @zunceng 是的,我测试了下 mysql 的 reverse,确实无错误
    SpiderShrimp
        7
    SpiderShrimp  
    OP
       Oct 24, 2019
    @reus 是呀,后来放弃 reverse 方案了。不过用 xorm 读取数据库表结构确实方便。
    About     Help     Advertise     Blog     API     FAQ     Solana     2410 Online   ighest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 45ms UTC 01:41 PVG 09:41 LAX 18:41 JFK 21:41
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86