Migration Class Names |
I'm having an issue with CI 3 migrations and I'm wondering if anyone else has run into this and how they fixed it.
If I have the following migration file: Code: 20121031100537_alter_blog.php Then I have the following migration class: PHP Code: Migration_Alter_blog If I need to alter the blog table again, however: Code: 20131031100537_alter_blog.php It has the same class name: PHP Code: Migration_Alter_blog And because of the way CI load and initializes migrations, it'll throw a PHP error for redeclaring a class. Is there a way around this that anyone has found? If not, what's the best practice for handling these naming conflicts? I've been able to get around it by adding the timestamp to the class name: PHP Code: Migration_Alter_blog_20131031100537 But that requires a filename of: Code: 20131031100537_alter_blog_20131031100537.php Which just feels messy. Any help or input is appreciated.
According to the documentation you either use an incremental index or timestamp.
From what you have shown is that your trying to use the same file without incrementing the value in the file name. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I just give more details. So, names like alter_blog_add_category, or alter_blog_remove_tags.
(08-04-2017, 03:47 AM)InsiteFX Wrote: According to the documentation you either use an incremental index or timestamp. No, I'm going from 2012... to 2013... in the example above, so I'm incrementing the timestamp as the documentation says, but the timestamp is just for the file name, not the class name. (08-04-2017, 07:39 AM)kilishan Wrote: I just give more details. So, names like alter_blog_add_category, or alter_blog_remove_tags. That's a good call. Simple. |
Welcome Guest, Not a member yet? Register Sign In |