Skip to content

createSchema reports success but mysql data base does show new schema #1379

Closed

Description

Trying to use sequelize's createSchema, copied script from documentation.

Here is the modified script I ran to create the unexpected results:

var db = require('./db_connection_mysql');

db.createSchema('my_data')
  .success(function()
      {
        console.log(' sequelize create schema succeeded');
        db.sync()
          .success(function() {
                      console.log('createschema stored on db-server');
                       })
          .error(function()
                 {
                   console.log('create schema failed: ');
                 })
      })
  .error(function(e)
      {
         console.log('createschema failed for sequelize: \n'+e);
      })
  ;

The module db_connect_mysql connects to the mysql database server
using the database name "mysql", userid: root, and with root's password.
I have tested this script. It has error checking to detect and report
errors. I have run this script that proved it is working correctly.
MySql workbench shows the connection.


Received:
node C:$work\node\staff_db\create_schema.js
Executing (default): SHOW TABLES
sequelize create schema succeeded
createschema stored on db-server

Press any key to continue . . .

when I look inside the database (using root) I do not see
the "my_data" schema, as being defined.
For some reason it appears that the createSchema resulted in a SQL command
of SHOW TABLES. Why I do not know.

My environment:
Up-to-date Windows 7 OS 64, Intel corei3
Oracle MySql - V5.6
Java Script modules:
node - V0.2.10
mysql - v2.0.1
sequelize - v1.7.0-rc5

Activity

  1. mickhansen commented on Feb 11, 2014

    @mickhansen
    Contributor

    MySQL does not support schemas. The way sequelize supports schemas for MySQL is by prefixing table names when models are defined and using a schema.

    Please show your models and the appropriate .schema() calls.

  2. janmeier commented on Feb 11, 2014

    @janmeier
    Member

    In mysql create schema is equivalent to create database
    http://dev.mysql.com/doc/refman/5.7/en/schemata-table.html

    So I don't think you could do select * from schema.table, you would have to
    specify use schema (which is actually a database) first. I also don't think
    you'd be able to query across multiple schemas.

    I'm wondering if create schema should actually throw an error for mysql, to
    avoid confusion..

  3. mickhansen commented on Feb 12, 2014

    @mickhansen
    Contributor

    Schemas in mysql are implemented as prefixes, as we decided back when the feature got implemented, that's fine for me - Makes it possible to query multiple schemas on the same connection like it works on postgres.

    I don't think we should change it to use and create multiple databases.

  4. mickhansen commented on Feb 12, 2014

    @mickhansen
    Contributor

    @janmeier reports that querying across multiple databases (or schemas if you will) is actually possible for mysql.

    So i suppose in the future an argument could be made for schemas in mysql to be supported using multiple databases - However this would massively break BC, so don't expect it to be introduced soon.

    Please let us know if schemas as prefixes do not work for you, and open a feature request for mysql schemas to be implemented as databases. Closing this.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions