Comments (3)
Hello Raúl,
Sorry for the delay, I haven't replied to your email until now because I've actually been looking for a solution to your problem that wouldn't involve adding a lot of new functionality to dbv.php
.
Shouldn't new revisions update the schema automatically?
They do, but they don't also update your schema files. Your user
table still exists on the disk, but now your database only has a users
table. You could remove the user.sql
file from your schema directory and then export users
to users.sql
, but that would mean that when a new developer would build the database, he would start with the users
table, and the revision that renames the non-existing user
table would throw an error.
The solution (at least for now) would be to change your revision script so that it only renames user
to users
if user
exists. Unfortunately, since MySQL doesn't provide a REPLACE IF EXISTS
(like it does for DROP IF EXISTS
), this needs a small trick. Try replacing your revision script with this:
SELECT COUNT(*)
INTO @exists
FROM information_schema.tables
WHERE table_schema = '[YOUR DATABASE NAME]'
AND table_name = 'user';
SET @query = IF (@exists > 0, 'RENAME TABLE user TO users', 'SELECT 1');
PREPARE statement FROM @query;
EXECUTE statement;
And then simply remove the user.sql
file and export the new users.sql
. When a new developer runs the revision script, because they don't actually have the user
table, no error will be raised, while those that actually have it will have it renamed.
Please let me know if this works for you :)
from dbv.
If anyone else is reading this, any suggestion on how to elegantly circumvent this problem is more than welcome!
from dbv.
It is ok for me, just wondering what is the "official" path to follow and if that scenario was expected.
Thanks for your reply, I will follow this issue.
from dbv.
Related Issues (20)
- Integration with dbdiff HOT 2
- css attempts to load google font over http HOT 1
- Suggestion for non-linear changes
- [Question] [Best Practices] Should I create a revision too when I create a new table
- [Question] [Best Practices] How to store initialization data for tables
- Cannot see the project website HOT 2
- All On Disk set to "No" HOT 3
- Feedback for errors in Revision scripts HOT 3
- Is this project abandoned? HOT 1
- data changes
- why it it too slow? HOT 1
- HTTP Authentication not working HOT 2
- use multiple databases
- GitHub - Integration
- Need for other Adapters?
- Website is currently down HOT 1
- Question for sigle user (From newbie)
- Problem: Same name for stored procedures and tables
- How to configure sql server adapter?
- Expired certificate on https://dbv.vizuina.com/ HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbv.