Well I just did a trivial test (see below) on the prod db and it worked. I
have no idea why it was broken (when I broke it the entire site was busted
so I didn’t spend a bunch of time trying to diagnose the problem).

—
mysql> CREATE TABLE `test_table` (`id` int(11) DEFAULT NULL auto_increment
PRIMARY KEY, x int(11));
Query OK, 0 rows affected (0.06 sec)

mysql> insert into test_table (x) values (1);
Query OK, 1 row affected (0.36 sec)

mysql> insert into test_table (x) values (2);
Query OK, 1 row affected (0.01 sec)

mysql> insert into test_table (x) values (3);
Query OK, 1 row affected (0.05 sec)

mysql> insert into test_table (x) values (4);
Query OK, 1 row affected (0.01 sec)

mysql> select * from test_table;
+----+------+
| id | x    |
+----+------+
|  1 |    1 |
|  2 |    2 |
|  3 |    3 |
|  4 |    4 |
+----+------+
4 rows in set (0.00 sec)

mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)

mysql> delete from test_table;
Query OK, 4 rows affected (0.00 sec)

mysql> select * from test_table;
Empty set (0.00 sec)

mysql> alter table test_table auto_increment=1;
Query OK, 0 rows affected (0.12 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> insert into test_table (x) values (10);
Query OK, 1 row affected (0.04 sec)

mysql> select * from test_table;
+----+------+
| id | x    |
+----+------+
|  1 |   10 |
+----+------+
1 row in set (0.01 sec)




On Tue, Apr 29, 2014 at 4:17 PM, Will Jordan <notifications@github.com>wrote:

> In lib/tasks/seed.rake:
>
> > @@ -196,32 +78,29 @@ namespace :seed do
> >    task trophies: :environment do
> >      # code in user.rb assumes that broze id: 1, silver id: 2 and gold id: 3.
> >      Trophy.transaction do
> > -      Trophy.delete_all # use delete instead of destroy so callbacks are not called
> > -      Trophy.connection.execute("ALTER TABLE trophies auto_increment = 1")
> > -      trophy_id = 0
> > -      Trophy.create!(id: trophy_id += 1, name: 'Bronze', image_name: 'bronzetrophy.png')
> > -      Trophy.create!(id: trophy_id += 1, name: 'Silver', image_name: 'silvertrophy.png')
> > -      Trophy.create!(id: trophy_id += 1, name: 'Gold', image_name: 'goldtrophy.png')
> > +      ApplicationHelper.reset_db(Trophy)
> > +      %w(Bronze Silver Gold).each do |trophy|
>
> i'll revert these changes if you think autoincrement is still broken on
> production, but I think we need to figure out how we can fix this (or
> figure out how to even test it).
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/code-dot-org/dashboard/pull/531/files#r12122403>
> .
>