lucky icon indicating copy to clipboard operation
lucky copied to clipboard

Lucky apps with no DB

Open jwoertink opened this issue 7 years ago • 3 comments

This recent commit https://github.com/luckyframework/lucky/commit/046b54b6147a748429107ed5dca085cc647f3c9e added a require for LuckyMigrator. When trying to boot my app, I got the error message saying database was nil since it requires a string.

Since I don't use LuckyRecord (which would be the same as anyone building a Lucky site without a DB), I added a file in my config with this

I added in this line to a file in my config:

LuckyRecord::Repo.configure do
  settings.url = "noop"
end

Lucky::RouteHelper.configure do
  settings.base_uri = "noop"
end

LuckyMigrator::Runner.configure do
  settings.database = "noop"
end

It would be nice to have a way to configure this so when updating to the latest, we didn't have to add random config stuff. Maybe this could be an extra cli config option to generate? I feel like we talked about this before, but I couldn't find record of it lol

jwoertink avatar Aug 08 '18 23:08 jwoertink

How does this exactly work? I run into issues when following the guide while running the setup script. The script complains I do not have postgres CLI tools installed (which is correct).

haarts avatar Apr 10 '21 14:04 haarts

Ah, I think we just need to update the setup script a bit more. This issue is actually out of date now.

Basically, you'd set your config/database.cr to look like this https://github.com/luckyframework/website/blob/master/config/database.cr

AppDatabase.configure do |settings|
  settings.credentials = Avram::Credentials.void
end

Avram.configure do |settings|
  settings.database_to_migrate = AppDatabase
end

This allows Avram to be configured, but without need to connect to a database. Then you'd have to update script/setup script to remove the calls to the db tasks (i.e. db.create, db.verify_connection, db.migrate, and the seeds). The Lucky website is a good example since it doesn't need a DB. https://github.com/luckyframework/website/blob/master/script/setup

jwoertink avatar Apr 10 '21 20:04 jwoertink

I got it to work! The website reference was brilliant.

haarts avatar Apr 10 '21 20:04 haarts

This is possible now that Avram is no longer required to run Lucky https://github.com/luckyframework/lucky/pull/1620 The next release will make this easier.

jwoertink avatar Aug 14 '22 17:08 jwoertink