GenieFramework / GenieFramework/SearchLight.jl

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

Open
#21 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
149
Forks
18
PR merge metrics
No merged PRs in 30d

Description

**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:
```julia
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)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with SearchLight.Generator.newresource("Demo.Game") and inspect the generated migration file named ..._create_table_demo.games.jl, especially its module declaration. Compare that output with the migration loading path shown in SearchLight/Migration.jl around lines 247–259. Re-run SearchLight.Migration.last_up() and confirm that the migration creates the game table in the demo schema without a Julia syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia, postgresql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.