csphere-cms / cSphere

Generic PHP Web-CMS with low footprint and high extensibility
Other
17 stars 7 forks source link

Database update function #13

Open micha-09 opened 10 years ago

micha-09 commented 10 years ago

For Plugin updates the database needs method to compare two database.xml files. If col exists in the first, but not in the second, remove the col. If col exitsts in the first and in the second do nothing If col doesnt exists in the first but in the secon add this col I think thats are all cases.

ebroda commented 10 years ago

Not just cols but also complete tables. The same three cases. It might happen that another table is added or one of the existing is deleted.

We should take an backup of the data (see #12) before the update so data which might be no longer served is not lost.

micha-09 commented 10 years ago

No because, if the developer add or remove or edit cols in a table this the conflict case. New tables in a plugin are easy to handle. They will be added. And tables that no more in update will be delete

ebroda commented 10 years ago

I didn't get your "no because". Your issue is named "Database update function", so new and removed complete tables are part of this function. And in your issue description is nothing said about tables.

micha-09 commented 10 years ago

ok i think i implement it by myself... The update function is need to update tables, because tables are parts of database i call the issue like this. Plugins deliver tables, you know? So my post are current.

ebroda commented 10 years ago

So have fun by implement it and take the issue for yourself...

I just wanted to say what I think is missing in your issue description. It was just an addition to what you wanted to do so far. The name of the issue is right. This is what the function should do. But in your description (1. comment) you're just talking about columns in a table. You're not saying anything about tables. It could be possible that i add a another table in the next release of my plugin and you have to check this also. Of course I know that plugins deliver tables. I just used them :-) But what happens if a complete table is removed or added. You didn't notice that if you just take a look at the columns. If a new table is added and you wanna add cols to it but the table doesn't exist so far, you get a problem.

So first of all you should compare the tables that exists for far and the tables the plugin want to have now. To have an exampe: Before: board, board_moderator After: board, board_reports So you have to remove board_moderator and have to add board_reports, right?

And after this step you could take a look at the tables (in this case board) that already existed and now might be changed what was your first idea in this issue.

hajo-p commented 10 years ago

the issue name should be database migrations or something alike. while many migrations could be automated there will be cases when that is not possible or takes a huge effort. so there should be a possibility to ship migration files for updates between versions of a plugin, e.g. in plain SQL that works for all four database drivers.

this issue will include a lot of work and will need a lot of stuff, so we should decide carefully how and what will be included, e.g. at our next team meeting.

micha-09 commented 10 years ago

yes but without this, no plugin updates are available!