Welcome Guest, Not a member yet? Register   Sign In
Best way to overwrite certain tables in db
#1

(This post was last modified: 09-13-2018, 07:54 AM by ignitedcms.)

What is the best way to overwrite certain tables in my database?

Should I use migrations?

Or should I do something like this.

#1 Drop the table that needs amending.
#2 Do a mysql insert with new table?

Thank you in advance.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#2

@ignitedcms,

I think it depends on the situation. Is there data in them there tables??? If so, are you sure that deleting it is the right path. If you are amending the table you could just do an alter table. I'm always cautious about deleting. I would prefer to backup then delete or if possible rename then recreate.
Reply
#3

(09-13-2018, 08:03 AM)php_rocs Wrote: @ignitedcms,

I think it depends on the situation.  Is there data in them there tables???  If so, are you sure that deleting it is the right path.  If you are amending the table you could just do an alter table. I'm always cautious about deleting.  I would prefer to backup then delete or if possible rename then recreate.

Hi thank you for your reply, essentially ONLY one table needs to remain, the rest can be dropped entirely and the new data inserted.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#4

@ignitedcms,

Oh, ok. Your just asking a straight database question. I thought is was related to a database with pre-existing data.
Reply
#5

This depends on what you need to do.

If you just need to add more fields then use the Alter Table.

If you need to change field names etc; Then you would need to drop the table
and create a new one.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

Thank you guys, I think I've got enough ideas to move forward with this.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply




Theme © iAndrew 2016 - Forum software by © MyBB