Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After throws an exception in a migration #515

Closed
tpow opened this issue Nov 12, 2021 · 0 comments · Fixed by #517
Closed

After throws an exception in a migration #515

tpow opened this issue Nov 12, 2021 · 0 comments · Fixed by #517
Assignees
Labels
bug An existing feature is not working as intended

Comments

@tpow
Copy link

tpow commented Nov 12, 2021

As mentioned in Slack, I was attempting to use after in a migration as shown in the documentation table.string('is_admin').after('email'). In Masonite-orm 1.0.55 it is throwing an exception "'NoneType' object is not callable" in masoniteorm/schema/Blueprint.py line 874. The line is self._last_column.after(old_column).

To Reproduce
Steps to reproduce the behavior:

  1. Create a basic migration like this (all boilerplate from craft migration -t users except for the added line from the documentation).
from masoniteorm.migrations import Migration                                     
                                                                                 
                                                                                 
class MigrationForUsersTable(Migration):                                         
    def up(self):                                                                
        """                                                                      
        Run the migrations.                                                      
        """                                                                      
        with self.schema.table("users") as table:                                
            table.string('is_admin').after('email')                              
                                                                                 
    def down(self):                                                              
        """                                                                      
        Revert the migrations.                                                   
        """                                                                      
        pass  
  1. Do the migration with craft migrate

The migration runs somewhat -- the is_admin column gets added to the end of the table, but not after the email column as intended. Because it throws the exception, the migration does not complete successfully.

What database are you using?

  • Type: MariaDB
  • Version 10.1something on Ubuntu
  • Masonite ORM v1.0.55

Other notes
Joseph Mancuso suggested that perhaps string is not setting _last_column.

I found this while trying to do a migration that alters several table columns and simplified it. It feels like the documentation for creating tables is pretty good, but altering them could use more examples.

@tpow tpow added the bug An existing feature is not working as intended label Nov 12, 2021
@josephmancuso josephmancuso self-assigned this Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An existing feature is not working as intended
Projects
Development

Successfully merging a pull request may close this issue.

2 participants