GenieFramework / SearchLight.jl

ORM layer for Genie.jl, the highly productive Julia web framework
https://genieframework.com
MIT License
139 stars 16 forks source link

create_migrations_table not found #40

Closed tlorans closed 2 years ago

tlorans commented 2 years ago

Describe the bug Try to follow this step in the tutorial. I run the following command:

SearchLight.Migration.create_migrations_table()

Error stacktrace

ERROR: UndefVarError: create_migrations_table not defined
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base ./Base.jl:26
 [2] top-level scope
   @ REPL[16]:1

To reproduce Just follow this step in the tutorial

Expected behavior Create the DB table used by SearchLight's migration system.

Additional context

Julia Version 1.6.4
Commit 35f0c911f4 (2021-11-19 03:54 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.5.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, westmere)
     Project Watchtonight v0.1.0
      Status `~/Documents/LearnGenie/3. DevelopingMVC/Watchtonight/Project.toml`
  [c43c736e] Genie v4.2.0
  [6d011eab] Inflector v1.0.1
  [e6f89c97] LoggingExtras v0.4.7
  [739be429] MbedTLS v1.0.3
  [0aa819cd] SQLite v1.3.0
  [340e8cb6] SearchLight v2.1.0 `https://github.com/GenieFramework/SearchLight.jl.git#master`
  [21a827c4] SearchLightSQLite v2.0.0 `https://github.com/GenieFramework/SearchLightSQLite.jl.git#master`
  [ade2ca70] Dates
  [56ddb016] Logging
FrankUrbach commented 2 years ago

Hi, I think you've forgotten something. In the tutorial you refer to the command looks like SearchLight.Migration.create_migrations_table(). You used SearchLight.create_migration_table() where the Migration is missing. Maybe this helps.

tlorans commented 2 years ago

Hi, I think you've forgotten something. In the tutorial you refer to the command looks like SearchLight.Migration.create_migrations_table(). You used SearchLight.create_migration_table() where the Migration is missing. Maybe this helps.

Yeah sorry it was an error in my copy paste to the issue editor, but I did run SearchLight.Migration.create_migrations_table() (and checked again to be sure).

essenciary commented 2 years ago

@tlorans it's there, it should work: https://github.com/GenieFramework/SearchLightSQLite.jl/search?q=create_migrations_table

Can you provide more info (the steps you're taking) so we can reproduce?

FrankUrbach commented 2 years ago

Would it be possible to save the whole project to GitHub so we can see where the error occurs? Without this it would be a guessing. Maybe the clause "using SearchLigthSQLite.jl" is missing somewhere. If this is the case SearchLight will not find the function because in SearchLight.jl the function is only abstract.

tlorans commented 2 years ago

Would it be possible to save the whole project to GitHub so we can see where the error occurs? Without this it would be a guessing. Maybe the clause "using SearchLigthSQLite.jl" is missing somewhere. If this is the case SearchLight will not find the function because in SearchLight.jl the function is only abstract.

Yes of course, please find the project here.

tlorans commented 2 years ago

@tlorans it's there, it should work: https://github.com/GenieFramework/SearchLightSQLite.jl/search?q=create_migrations_table

Can you provide more info (the steps you're taking) so we can reproduce?

this step in the tutorial

Yes, so using this project.

I run:

]pkg activate .
]pkg instantiate

using Genie
using Watchtonight
using SearchLight
SearchLight.Migration.create_migrations_table()

And now I've got this as output:

ERROR: MethodError: no method matching create_migrations_table()
Stacktrace:
 [1] top-level scope
   @ REPL[7]:1

I think I'm just lost in the various steps and environments following this issue.

FrankUrbach commented 2 years ago

Your script should be looking like this:

]pkg activate .
]pkg instantiate

using Genie
using Watchtonight
using SearchLight
using SearchLightSQLite

config_file = "Your path/to_your yml/connection.yml"
dict_config = SearchLight.Configuration.read_db_connection_data(config_file)
SearchLight.connect(dict_config)

SearchLight.Migration.create_migrations_table()

A little bit explanation:

I noticed during the tests that for now the SearchLight package can have some trouble with version numbers. If the error message comes up again, try the following:

  1. push ]
  2. rm SearchLightSQLite
  3. rm SearchLight
  4. add SearchLight
  5. add SearchLightSQLite

This will reinstall SearchLight and eventual upcoming version clashes should go away.

HTH Frank

tlorans commented 2 years ago

@FrankUrbach Thank you so much! It works perfectly !

FrankUrbach commented 2 years ago

Now you are up and running 👍 . The next time you have some trouble feel free to ask on Gitter: https://gitter.im/essenciary/Genie.jl or on Discord: https://discord.gg/G9hGxUTE. For now the community is more active on Gitter. It would be cool if you could close the issue and mark it as solved.

tlorans commented 2 years ago

I will :)

tlorans commented 2 years ago

Hello,

Finally I still have an issue in the following steps in the tutorial (after having run the commands you mentioned @FrankUrbach ).

I run:

SearchLight.Migration.status()
SearchLight.Migration.last_up()
``` 

And get the following output:

``` 
ERROR: BoundsError: attempt to access 0-element Vector{String} at index [0]
Stacktrace:
 [1] getindex
   @ ./array.jl:805 [inlined]
 [2] last_migration
   @ ~/.julia/packages/SearchLight/B9d2o/src/Migration.jl:266 [inlined]
 [3] #last_up#11
   @ ~/.julia/packages/SearchLight/B9d2o/src/Migration.jl:155 [inlined]
 [4] last_up()
   @ SearchLight.Migration ~/.julia/packages/SearchLight/B9d2o/src/Migration.jl:155
 [5] top-level scope
   @ REPL[12]:1

I think this is related to the fact that in the previous steps, when running:

Genie.newresource("movie")
┌ Error: UndefVarError(:UserApp)
└ @ Genie ~/.julia/packages/Genie/BAbYR/src/genie_module.jl:261

And the file ending by _create_movies_players.jl is not automatically created, I had to create it manually without knowing what to put as name of the file (other than the ending).

FrankUrbach commented 2 years ago

I tried to follow your path and changed your things a little bit:

using Genie
using SearchLight
using SearchLightSQLite

Genie.loadapp() # needed to run thew newsource function without an error
Genie.newresource("movie") # create the ressource for you
SearchLight.Migration.status()   # should work now
SearchLight.Migration.last_up() # shows an error in my environment maybe this isn't the case for you

HTH Frank

tlorans commented 2 years ago

I tried to follow your path and changed your things a little bit:

using Genie
using SearchLight
using SearchLightSQLite

Genie.loadapp() # needed to run thew newsource function without an error
Genie.newresource("movie") # create the ressource for you
SearchLight.Migration.status()   # should work now
SearchLight.Migration.last_up() # shows an error in my environment maybe this isn't the case for you

HTH Frank

Hello,

Sorry for the delay. Thank you for your try, I still have the same issue than you. Nevermind, I will use directly SQLite! Think I should close this issue then, as this blocking error is not exactly the same than the initial problem of this issue.

Best regards and thank you again!

FrankUrbach commented 2 years ago

I think we could change to Discord. I saw the problem by reading the generated migration file. There you have to specify what columns you want to include. But lets us discuss this on Discord.