MasoniteFramework / orm

Masonite ORM is a beautiful Python ORM. It's also a nearly drop in replacement of the Orator ORM
https://orm.masoniteproject.com
MIT License
179 stars 49 forks source link

Migration hierarchy not working #626

Closed yubarajshrestha closed 2 years ago

yubarajshrestha commented 2 years ago

Describe the bug If you have multiple migrations in package development then we need a way to maintain the hierarchy of migrations.

To Reproduce Steps to reproduce the behavior:

  1. Start basic package development
  2. Add few migration files with relations in it
  3. Try to migrate and see the order of migrations created

Expected behavior Should be able to maintain the order of migrations registered.

girardinsamuel commented 2 years ago

Summarizing the specs to fix this issue here (from Discord):

👉 The proposed solution was to add an index in the migration filename: {timestamp}_{index}_{name}.py. This index would be computed based on the list of existing migrations in the migrations folder.

@josephmancuso is that correct ?

girardinsamuel commented 2 years ago

@yubarajshrestha Are you okay with the specs above ?

yubarajshrestha commented 2 years ago

@yubarajshrestha Are you okay with the specs above ?

Yes, you're right. You should order those migrations based_on order of migrations added in migrations.

.migrations(
                "migrations/first_table.py",
                "migrations/secon_table.py",
                "migrations/third_table.py",
            )
girardinsamuel commented 2 years ago

Yes, you're right. You should order those migrations based_on order of migrations added in migrations.

☝️ Yes you're right. But that become a Masonite issue then. I will transfer this issue to the Masonite repo.

josephmancuso commented 2 years ago

I think this is solve https://github.com/MasoniteFramework/masonite/blob/4.0/src/masonite/packages/providers/PackageProvider.py#L150

yubarajshrestha commented 2 years ago

I think this is solve https://github.com/MasoniteFramework/masonite/blob/4.0/src/masonite/packages/providers/PackageProvider.py#L150

@josephmancuso if you try to migrate the migration with above solution that will give you error if you try migrating.