We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting error while using with gorm.
DB.AutoMigrate(&VSettings{}) throws
DB.AutoMigrate(&VSettings{})
2021/05/26 13:35:13 src/ramsql.go:83 Syntax error near BIGINT UNSIGNED not [0.094ms] [rows:0] CREATE TABLE `vsettings` (`id` BIGINT UNSIGNED NOT NULL,`vid` BIGINT UNSIGNED NOT NULL,`tid` BIGINT UNSIGNED NOT NULL,`settings` JSON NOT NULL,`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,PRIMARY KEY (`id`)) 2021/05/26 13:35:13 Syntax error near BIGINT UNSIGNED not
import ( "database/sql" "encoding/json" _ "github.com/proullon/ramsql/driver" "gorm.io/datatypes" "gorm.io/driver/mysql" "gorm.io/gorm" "log" "time" ) type ID uint64 // VSettings [...] type VSettings struct { ID ID `gorm:"id;type:BIGINT UNSIGNED NOT NULL;primaryKey;autoIncrement;"` VID ID `gorm:"vid;type:BIGINT UNSIGNED NOT NULL;"` TID ID `gorm:"tid;type:BIGINT UNSIGNED NOT NULL;"` Settings datatypes.JSON `gorm:"settings;type:JSON;NOT NULL" json:"settings"` CreatedAt time.Time `gorm:"created_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP;"` UpdatedAt time.Time `gorm:"updated_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP;OnUpdate:CURRENT_TIMESTAMP;"` //DeletedAt *time.Time `gorm:"deleted_at;type:TIMESTAMP"` } // TableName get sql table name. func (m *VSettings) TableName() string { return "vsettings" } func main() { sqlDB, err := sql.Open("ramsql", dbDSN) if err != nil { log.Fatalf("sql.Open : Error : %v\n", err) } defer func(db *sql.DB) { err := db.Close() if err != nil { log.Fatalf("sqlDB.Close : Error : %v\n", err) } }(sqlDB) DB, err := gorm.Open( mysql.New( mysql.Config{ Conn: sqlDB, SkipInitializeWithVersion: true, }, ), &gorm.Config{ DisableForeignKeyConstraintWhenMigrating: true, }, ) if err != nil { log.Fatalf("gorm.Open : Error : %v\n", err) } err = DB.AutoMigrate(&VSettings{}) if err != nil { log.Println(err) log.Fatalf("AutoMigrate VSettings : Error : %v\n", err) } }
The text was updated successfully, but these errors were encountered:
Same for me:
[0.141ms] [rows:0] CREATE TABLE `channels` (`id` bigint unsigned AUTO_INCREMENT,`created_at` datetime(3) NULL,`updated_at` datetime(3) NULL,`deleted_at` datetime(3) NULL,`created` datetime(3) NULL,`channel_identifier` varchar(500),`user_identifier` varchar(500),`time_zone` longtext,`daily_reminder` bigint unsigned,`calendar_secret` varchar(191),`role` longtext,PRIMARY KEY (`id`),INDEX idx_channels_deleted_at (`deleted_at`),INDEX idx_channels_channel_identifier (`channel_identifier`),INDEX idx_channels_user_identifier (`user_identifier`),INDEX idx_channels_calendar_secret (`calendar_secret`)) --- FAIL: TestDatabase_Initialize (0.00s) database_test.go:49: Error Trace: database_test.go:49 Error: Received unexpected error: Syntax error near bigint unsigned AUTO_INCREMENT Test: TestDatabase_Initialize Messages: Failure on initializing the database: Syntax error near bigint unsigned AUTO_INCREMENT FAIL exit status 1 FAIL github.com/CubicrootXYZ/matrix-reminder-and-calendar-bot/internal/database 0.012s
The auto migrate does not work as the bigint unsigned AUTO_INCREMENT is invalid to ramsql.
bigint unsigned AUTO_INCREMENT
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Getting error while using with gorm.
Error
DB.AutoMigrate(&VSettings{})
throwsMy implementation for clubbing with gorm
The text was updated successfully, but these errors were encountered: