Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBUtil cannot create table with SQLite #1985

Open
Art4 opened this issue Feb 27, 2016 · 2 comments
Open

DBUtil cannot create table with SQLite #1985

Art4 opened this issue Feb 27, 2016 · 2 comments

Comments

@Art4
Copy link
Contributor

Art4 commented Feb 27, 2016

I have created and configurate a SQLite database connection and want to run the migrations.

If I execute the migration with

env FUEL_ENV=test php oil refine migrate:current

I got this error:

Uncaught exception Fuel\Core\Database_Exception: SQLSTATE[HY000]: General error: 1 near "DEFAULT": syntax error with query: "CREATE TABLE IF NOT EXISTS `fuel_migration` (
    `type` varchar(25) NOT NULL,
    `name` varchar(50) NOT NULL,
    `migration` varchar(100) DEFAULT '' NOT NULL
)DEFAULT CHARACTER SET utf8;"
Callstack: 
#0 .../fuel/core/classes/database/query.php(305): Fuel\Core\Database_PDO_Connection->query(0, 'CREATE TABLE IF...', false)
#1 .../fuel/core/classes/dbutil.php(149): Fuel\Core\Database_Query->execute(NULL)
#2 .../fuel/core/classes/migrate.php(611): Fuel\Core\DBUtil::create_table('fuel_migration', Array)
#3 .../fuel/core/classes/migrate.php(74): Fuel\Core\Migrate::table_version_check()
#4 [internal function]: Fuel\Core\Migrate::_init()
#5 .../fuel/core/classes/autoloader.php(375): call_user_func('Migrate::_init')
#6 .../fuel/core/classes/autoloader.php(249): Fuel\Core\Autoloader::init_class('Migrate')
#7 [internal function]: Fuel\Core\Autoloader::load('Migrate')
#8 .../fuel/core/tasks/migrate.php(282): spl_autoload_call('Migrate')
#9 .../fuel/core/tasks/migrate.php(161): Fuel\Tasks\Migrate::_current('default', 'app')
#10 .../fuel/core/base.php(455): Fuel\Tasks\Migrate->__call('current', Array)
#11 .../fuel/core/base.php(455): Fuel\Tasks\Migrate->current()
#12 .../fuel/packages/oil/classes/refine.php(108): call_fuel_func_array(Array, Array)
#13 [internal function]: Oil\Refine::run('migrate:current', Array)
#14 .../fuel/packages/oil/classes/command.php(126): call_user_func('Oil\\Refine::run', 'migrate:current', Array)
#15 /oil(65): Oil\Command::init(Array)
#16 {main}

If I excecuted the query directly in sqlite3 without the charset:

CREATE TABLE IF NOT EXISTS `fuel_migration` (
    `type` varchar(25) NOT NULL,
    `name` varchar(50) NOT NULL,
    `migration` varchar(100) DEFAULT '' NOT NULL
);

and the table was created. Something seems to be wrong with the charset.

@WanWizard
Copy link
Member

The current DBUtil, and most of the query builder, generates MySQL type ANSI SQL. Which isn't compatible with most other platforms.

I've started working on this with the goal to release full multi-platform support with 1.8.

@WanWizard
Copy link
Member

Didn't get around to it before releasing 1.8 (which was needed because of PHP7 compatibility).

But there is now a schema class which is used by DBUtil, which can be overloaded per driver type, so it is possible to implement this. I'll see if I can get around to doing this later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants