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

[Proposal] Add table prefix option to config/database.js #58

Closed
thetutlage opened this issue Oct 4, 2016 · 1 comment
Closed

[Proposal] Add table prefix option to config/database.js #58

thetutlage opened this issue Oct 4, 2016 · 1 comment

Comments

@thetutlage
Copy link
Member

@nicklaw5 commented on Sat Sep 24 2016

As far as I can see there is no option to provide a table prefix for creating tables with migrations.

Would be great if we could add an option to config/database.js to include this:

./config/database.js

...
  mysql: {
    client: 'mysql',
    connection: {
      host: Env.get('DB_HOST', 'localhost'),
      user: Env.get('DB_USER', 'root'),
      password: Env.get('DB_PASSWORD', ''),
      database: Env.get('DB_DATABASE', 'adonis'),
      tablePrefix: Env.get('DB_TABLE_PREFIX', 'ad_')
    }
  },

./.env.example

...
DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_USER=root
DB_PASSWORD=
DB_DATABASE=adonis
DB_TABLE_PREFIX=ad_

@thetutlage commented on Sun Sep 25 2016

Will add it in new release


@tux-world commented on Sun Sep 25 2016

@thetutlage which date new version maybe released?

@1mursaleen
Copy link

1mursaleen commented Oct 31, 2019

@thetutlage
defining a table prefix and then running "adonis migration:run" on an empty database gives this "error: relation "ec_4m3b2o87grf8w_adonis_schema_lock" does not exist".

Two tables are created before this error is thrown, "adonis_schema" and "adonis_schema_lock".

So the above two tables are being created without the prefix and then called with the prefix.

It seems that while developing the 'table prefix' feature, the team did not refactor that the prefix should also effect the above default hard coded tables.

Regenerate Error: Follow the Adonisjs documentation to add prefix to tables then run migration and see the magic happen.

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

No branches or pull requests

2 participants