cfwheels-dbmigrate-plugin icon indicating copy to clipboard operation
cfwheels-dbmigrate-plugin copied to clipboard

Allow creation of composite keys

Open tdm00 opened this issue 13 years ago • 4 comments

When creating a join table, it would be great if I could do this.

t = createTable(name='taggings',primaryKey='tagid,articleid'); t.integer('tagid'); t.integer('articleid'); t.timestamps(); t.create();

thanks

tdm00 avatar Sep 12 '11 14:09 tdm00

Checkout what Chris Peters did for this as posted at https://github.com/clearcrystalmedia/Administrivia/blob/master/db/migrate/Migration.cfc

tdm00 avatar Sep 13 '11 12:09 tdm00

I'm wondering if this needs to be coded this way, or if it's possible to just use the execute() command to do the same, although that does require SQL specific code.

tdm00 avatar Sep 15 '11 17:09 tdm00

It could have been coded using execute(), but I wasn't aware of the function's existence when I wrote that CFC. (Or I simply forgot about it.)

I really like your syntax in the description above. It matches what the Rails composite_migrations plugin does: http://errtheblog.com/posts/14-composite-migrations

chrisdpeters avatar Sep 15 '11 19:09 chrisdpeters

I agree that I prefer the syntax above. In the meantime, using the execute() function works until I can add this:

Example:

execute('ALTER TABLE mydb.taggings ADD PRIMARY KEY (tagid,callid);'); execute('ALTER TABLE mydb.taggings DROP PRIMARY KEY');

tdm00 avatar Sep 16 '11 20:09 tdm00