Open ghost opened 8 years ago
I see the create table command is being issued within openresty. How are you executing that code?
If I simply paste it into app.lua with nothing else, it will throw the same error.
local proj = { }
proj.lapis = require( "lapis" )
proj.app = proj.lapis.Application( )
proj.util = require( "lapis.util" )
proj.model = require( "lapis.db.model").Model
local db = require("lapis.db")
local schema = require("lapis.db.schema")
local types = schema.types
schema.create_table( 'users', {
{ 'id', types.id },
{ 'username', types.varchar( 20 ) },
{ 'password', types.varchar( 255 ) },
{ 'salt', types.varchar( 255 ) },
{ 'email', types.varchar( 255 ) },
{ 'joindate', types.date },
{ 'usergroup', types.varchar( 32 ) }
} )
Since I'm using Vagrant, I can send you the Vagrantfile and my project folder so you can boot up and toy around with my installation. That is, if you wanted to.
I'm going to see if I can start over on a fresh machine again and if the same results occur, I can copy the necessary files for starting up my Vagrant machine.
I didn't get a chance to try to reproduce it yet, let me try on my system before I check out the environment.
In the meantime, is there a workaround I could use? Perhaps specific versions of the software required? I was just starting to work with the model and I'm trying to write a script that creates all of the tables if they don't already exist, i.e. when the application is run for the first time.
Sorry for the delay. I hope you were able to figure something out in the meantime.
The issue is that you can't run queries in the initialization phase of lapis. You can either run it on the command line independently of openresty, or run it in an action that matches a request.
Here's the offending code:
Which produces this result:
I'm using the newest LuaJIT from their Git (2.0.4) along with OpenResty (1.9.7.1) and Lapis (1.4.0) from LuaRocks. I'm totally new to this stuff, so if there's anything else I should provide I'll be happy to do so.