sqlite 3 add foreign key error

Hi,

i’m trying to add a foreign key to my table, but when i try to do that i receive the:

Adding a foreign key constraint to an existing table is not supported by SQLite.




		$this->addForeignKey('fk_user', 'tbl_data', 'id_responsable','tbl_user', 'id', 'CASCADE');

		

		$this->createTable('tbl_data', array(

                  'id' => 'pk',

                  'name' => 'string',

	 	  'id_responsable' => 'integer',

        ));



If i put the foreign key in the end i have the same problem… someone know how to solve it?

Thanks.

its telling you exactly what the problem is

"Adding a foreign key constraint to an existing table is not supported by SQLite."

google it and you will find some solutions like

backup the data in the table delete the table and create it again with the foreign key and copy back the data

I saw that.

But how can i do that on the migration… in this case first i add the foreign key… if i remove the create table i have the same problem…

Is there a way to do that on the migration… i delete my testbase.db before i run the migration.

Thanks