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

Error thrown when trying to create migration file for PostgreSQL table within a specific schema #21

Open balcanicus opened 4 years ago

balcanicus commented 4 years ago

Unable to use table migrations with custom schema for PostgreSQL adapter When trying to create migration files for PostgreSQL with tables in custom schema's the "up" action throws an error (shown below).

Error stacktrace julia> SearchLight.Migration.last_up() │┌ Error: 2019-11-15 20:23:23 Failed executing migration CreateTableDemo.games up │└ @ SearchLight.Migration ~/.julia/packages/SearchLight/c2vea/src/Migration.jl:259 │ERROR: LoadError: syntax: invalid identifier name "." │Stacktrace: │ [1] top-level scope at xxxxxxx/db/migrations/2019111519212379_create_table_d │emo.games.jl:1 │ [2] include at ./boot.jl:328 [inlined] │ [3] include_relative(::Module, ::String) at ./loading.jl:1094 │ [4] include at ./Base.jl:31 [inlined] │ [5] include at xxxxxxx/.julia/packages/SearchLight/c2vea/src/Migration.jl:4 [inlined] │ [6] #run_migration#17(::Bool, ::typeof(SearchLight.Migration.run_migration), ::SearchLight.Migration.Database │Migration, ::Symbol) at xxxxxxx/packages/SearchLight/c2vea/src/Migration.jl:247 │ [7] #run_migration at ./none:0 [inlined] │ [8] #last_up#7 at xxxxxxx/.julia/packages/SearchLight/c2vea/src/Migration.jl:119 [inlined] │ [9] last_up() at xxxxxxx/.julia/packages/SearchLight/c2vea/src/Migration.jl:119 │ [10] top-level scope at REPL[9]:1 │in expression starting at xxxxxxx/db/migrations/2019111519212379_create_table │_demo.games.jl:1

To reproduce

  1. While in REPL generate migration files with: SearchLight.Generator.newresource("Demo.Game")
  2. Edit the file named "..._create_table_demo.games.jl". Updates done were related only to column definition(s). The resulting content of the file is shown below:
    
    module CreateTableDemo.games

import SearchLight.Migrations: create_table, column, primary_key, add_index, drop_table

function up() create_table(:demo.games) do [ primary_key() column(:description, :string) ] end

add_index(:demo.games, :description) end

function down() drop_table(:demo.games) end

end

3. Attempt to "up" the migration by calling "SearchLight.Migration.last_up()" from REPL
4. REPL throws an errow described above

**Expected behavior**
Creation of a table called 'game' in a schema called 'demo'.

**Additional context**
julia> versioninfo()
  │Julia Version 1.2.0
  │Commit c6da87ff4b (2019-08-20 00:03 UTC)
  │Platform Info:
  │  OS: macOS (x86_64-apple-darwin18.6.0)
  │  CPU: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
  │  WORD_SIZE: 64
  │  LIBM: libopenlibm
  │  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
  │Environment:
  │  JULIA_REVISE = auto

pkg> st │ Status xxxxxxx/Project.toml │ [c43c736e] Genie v0.21.0 #master (https://github.com/GenieFramework/Genie.jl.git) │ [e6f89c97] LoggingExtras v0.4.0 │ [295af30f] Revise v2.3.0 │ [340e8cb6] SearchLight v0.15.0 #master (https://github.com/GenieFramework/SearchLight.jl.git)