dart-backend / angel

A polished, production-ready backend framework in Dart for the VM, AOT, and Flutter.
https://github.com/dukefirehawk/angel
BSD 3-Clause "New" or "Revised" License
171 stars 22 forks source link

Migratoins run multiple times #135

Open Garthi opened 1 week ago

Garthi commented 1 week ago

Hi, we found a problem, when you run the migrations multiple times it was executed runs again and again

here is my migration table

mysql> select * from migrations;
+----+-------+-------------------------------------------------------------------------+
| id | batch | path                                                                    |
+----+-------+-------------------------------------------------------------------------+
|  1 |     1 | /app/lib/entity/user.g.dart#UserNameMigration                           |
|  2 |     1 | /app/lib/entity/user.g.dart#UserMigration                               |
|  3 |     1 | /app/lib/entity/user.g.dart#UserTodoMigration                           |
|  4 |     1 | /app/lib/entity/car.g.dart#CarMigration                                 |
|  5 |     2 | /app/lib/entity/user.g.dart#UserMigration                               |
|  6 |     2 | /app/lib/entity/user.g.dart#UserTodoMigration                           |
|  7 |     2 | /app/lib/entity/car.g.dart#CarMigration                                 |
+----+-------+-------------------------------------------------------------------------+

and here is the log from the migration

[MysqlMigrationRunner] INFO 2024-07-04 15:47:03.397344: Check and create "migrations" table
[MysqlMigrationRunner] INFO 2024-07-04 15:47:03.402157: Added "/app/lib/entity/user.g.dart#UserMigration" into "migrations" table.
[MysqlSchema] SEVERE 2024-07-04 15:47:03.403869: Failed to run query: [ CREATE TABLE user (
  id serial,
  nick varchar(255)
);
 ]
[MysqlSchema] SEVERE 2024-07-04 15:47:03.404536: Failed to run query in a transaction
[MysqlMigrationRunner] INFO 2024-07-04 15:47:03.405977: Added "/app/lib/entity/user.g.dart#UserTodoMigration" into "migrations" table.
[MysqlSchema] SEVERE 2024-07-04 15:47:03.406728: Failed to run query: [ CREATE TABLE user_todo (
  id serial,
  user_id int,
  title varchar(10) NOT NULL,
  is_complete boolean DEFAULT false
);
 ]
[MysqlSchema] SEVERE 2024-07-04 15:47:03.407147: Failed to run query in a transaction

i'm not sure why the UserNameMigration runs only one time, but the other Migrations runs again and again

the UserNameMigration, UserMigration, UserTodoMigration was in one autogenerated file in this direction the CarMigration was in a manual created migration file

have you any idea why it runs multiple times, or is it a bug from the migration runner?

dukefirehawk commented 1 week ago

This looks like a bug. Will take a look.