glen
Make Mariadb / Mysql the default database instance instead of requiring -database flag
Is there a way to change the default database instance from Postgres to Mariadb or Mysql for ecto? I am aware of the option to use the database flag, but since I have years more experience with mysql, I’d love to make it the default.
Most Liked
kokolegorille
I would recommend to use postgresql if You want to follow tutorials, because there are some differences with mysql. Almost all tutorials I saw use it.
like ordering, or search case sensitivity, or extensions (citext, postgis etc).
I have often used mysql with Rails, but once I had to use windows functions. I don’t know if it is supported by mysql now, but 5 years ago it was not.
It’s always possible to switch later.
John-Goff
I would recommend using postgres, I started with MySQL and while it worked fine, there was a subset of ecto features that I wanted to use which required using postgres. Though switching from mysql to postgres was relatively painless all things considered, so if you do decide to go with one and then change your mind it should be doable. But yeah I wouldn’t bother modifying the script for phx.new, just use the --database flag or like I said earlier, wrap it in a bash script.
John-Goff
I do not believe that there is any kind of config file or anything that you could set to make your choice of database the default. I think that generally the generators are only used once when creating a project, so I’m not sure that adding such an option would be all that beneficial. If you are in fact creating new Phoenix projects on the regular you could always create a bash script which passes the flags you would like.
kokolegorille
You can always make some kind of shell alias if You really want to avoid typing –database mysql.
But You cannot change default value of phx.new
OvermindDL1
You could, however, fork it and make your own version to change the default and install your fork locally. ^.^
Seems like it would be a pretty minimal patchset to keep in sync. Maybe even PR it looking in a config in $XDG_CONFIG_HOME somewhere for what default config options for it to set (don’t forget to log to user that it found a config file at a given location and is using it for defaults so it’s not silently surprising).








