Friday, February 15, 2013

Re: Cakephp 2.x - Changing the name of a table within the schema

Not sure if it is possible using the core CakePHP schema tool.

If I was to attempt this, I would investigate what events are sent to
the before() method. If you find something that works. Then run
ClassRegistry::init('Model')->query('RENAME ...').

Take a look at how I pre-populated a user table after I created it:
https://gist.github.com/sime/1917192

I must say I religiously used the schema tool for migrations, until I
discovered the Migrations plugin by CakeDC.


On Fri, Feb 15, 2013 at 3:43 AM, fr3nch13 <fr3nch13@gmail.com> wrote:
> Is there a way to change the name of a table (tables) within the database
> schema?
>
> reference:
> (http://book.cakephp.org/2.0/en/console-and-shells/schema-management-and-migrations.html)
>
> I was unable to find out how to do this via googling, or searching the
> api/book.
>
> Basically this is what I'm trying to do:
>
> 1. I have a table named say 'cars'. I want to change the table name to
> 'vehicles'.
> 2. I would like to be able to do this within the built in schema.
> 3. I don't want to drop the old table and create a new one.
>
> The only way have come up with to do this would be to do something in the
> before() function.
> and do something like this:
> http://dev.mysql.com/doc/refman/5.0/en/rename-table.html
>
> I haven't tested this idea as I don't want to actually change anything.
> Is this the only way?
> Will cakephp recognize the change instead of resorting to looking at it's
> own cache?
>
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscribe@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Simon Males

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: