-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
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
Columns having default values not recognized by mariadb #39
Comments
So basically your default is a function call. This default here is SQLite specific and won't work in MySQL "createdAt" datetime(3) NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')) The MySQL/MariaDB equivalent would be `createdAt` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP Obviously, this won't work out of the box and would have to be properly translated and/or adapted. Translating custom functions like that is way out of scope for this package, however, feel free to submit a PR (with tests) for this if you really need the feature. |
Hi all, I have the same issue with a domoticz database which I am trying to get to MySQL. All DATETIME fields in the domoticz sqlite database have a default value of datetime('now', 'localtime'). I will try to fork the project and see if I can create a workaround for this. Cheers, Friso |
A PR would be most welcome. Make sure to include tests with it 😊 |
How would you like to receive those tests? Possible solution to this issue: thinking of creating a list of ways to set the default date in sqlite to the current timestamp. In the example of @fflorent , this is done using strftime. In my own example, it's done with datetime. As soon as the script detects a datetime and a default to the current timestamp, it will use the 'DEFAULT CURRENT_TIMESTAMP' code. |
Written in the same manner as those in the tests directory. You'll probably have to mock a lot of stuff and make fake tables using |
Not sure I'd even go down this route, to be honest. These things aren't just incompatible but a function call can be anything, so you'd have to make a crazy long list and keep it up to date. Even doing the data type translation was annoying. If you ask me, I'd just skip the transfer of the |
@fwieringen This here might help https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html |
Describe the bug
I have a sqlite file with this table:
When using
sqlite3-to-mysql
, I get an errorExpected behaviour
I don't expect error. However, I don't have a clear idea how to fix it properly.
Actual result
I get the following error:
System Information
Additional context
Add any other context about the problem here.
In case of errors please run the same command with
--debug
. This option is only available on v1.4.12 or greater.The text was updated successfully, but these errors were encountered: