CodeIgniter Forums
Setting start value for auto increment field with ci migrations - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Setting start value for auto increment field with ci migrations (/showthread.php?tid=56780)



Setting start value for auto increment field with ci migrations - El Forum - 01-19-2013

[eluser]xtremer360[/eluser]
Earlier today I signed up for a nettuts plus account and have been watching this series on codeigniter cms building. I am creating a migration file to create my users table. With my user ids I prefer to work with user ids that look like this 10000 and increment to 10001 for the next inserted user. What I'm trying to figure out was how do I setup so that when it creates the users table then to have the key start at 10000

https://tutsplus.com/course/build-a-cms-in-codeigniter/

After looking around I am not able to find out how to accomplish this. If anyone knows please help me out.



Setting start value for auto increment field with ci migrations - El Forum - 01-19-2013

[eluser]Aken[/eluser]
http://stackoverflow.com/questions/2130635/how-to-make-a-primary-key-start-from-1000


Setting start value for auto increment field with ci migrations - El Forum - 01-19-2013

[eluser]xtremer360[/eluser]
My fault I'm trying to figure out how to accomplish this with migrations.


Setting start value for auto increment field with ci migrations - El Forum - 01-20-2013

[eluser]xtremer360[/eluser]
Does anybody know?


Setting start value for auto increment field with ci migrations - El Forum - 01-20-2013

[eluser]Aken[/eluser]
Just run the ALTER TABLE query using $this->db->query().


Setting start value for auto increment field with ci migrations - El Forum - 01-20-2013

[eluser]xtremer360[/eluser]
Inside the migrations file?


Setting start value for auto increment field with ci migrations - El Forum - 01-20-2013

[eluser]xtremer360[/eluser]
Is this how?


Setting start value for auto increment field with ci migrations - El Forum - 01-20-2013

[eluser]Aken[/eluser]
In the 8 1/2 hours in between those two posts, you couldn't just TRY it? Yes in the migrations file; you asked about migrations after all...


Setting start value for auto increment field with ci migrations - El Forum - 01-24-2013

[eluser]xtremer360[/eluser]
It works but I was curious as to why when you set the primary key you can't tell it to start at 10000 when you set the key.


Setting start value for auto increment field with ci migrations - El Forum - 01-24-2013

[eluser]Aken[/eluser]
You can if you write the query yourself. CI does not have that feature. If you think it should be added, bring it up on Github.