Beispiel #1
0
 def migrate(self, revision):
     """
     Perform any migration operations that need to be executed.
     """
     self.step_sub_label('Running database migration.')
     with paths.cd_release(revision):
         django.manage('syncdb')
Beispiel #2
0
def migrate(migration=None, revision=None, user=DeployUser, **kwargs):
    """
    Apply migrations.

    :param revision: revision of the application to run show migrations from.
    :param migration: name of the migration to revert to, leave None to apply
        all migrations.

    """
    args = [migration] if migration else None
    django.manage('migrate', args, revision, user=user, **kwargs)
Beispiel #3
0
def show_migrations(revision=None, non_applied_only=False):
    """
    Print report of migrations.

    :param revision: revision of the application to run show migrations from.
    :param non_applied_only: only show un-applied migrations.

    """
    if non_applied_only:
        with settings(hide('warnings'), warn_only=True):
            result = django.manage('migrate', args=['--list | grep -v "(\*)"'], revision=revision, use_sudo=False)
        if result:
            if result.find('( )') != -1:
                print(colors.red('*'*34))
                print(colors.red('* Migrations need to be applied! *'))
                print(colors.red('*'*34))
            else:
                print(colors.green('Migrations up to date.'))
        else:
            print(colors.magenta('No migrations defined/or not using south.'))
    else:
        django.manage('migrate', ['--list'], revision=revision, use_sudo=False)
Beispiel #4
0
    def test_django_manage_simple_command(self):
        django.manage('test')

        self.assertSudo('python manage.py test --noinput',
                        user=DeployUser.sudo_identity())
Beispiel #5
0
    def test_django_manage_use_sudo_with_user(self):
        django.manage('test', use_sudo=True, user='******')

        self.assertSudo('python manage.py test --noinput', user='******')
Beispiel #6
0
    def test_django_manage_dont_use_sudo(self):
        django.manage('test', use_sudo=False)

        self.assertRun('python manage.py test --noinput')
Beispiel #7
0
    def test_django_manage_command_with_input(self):
        django.manage('test', ['--arg1 234', '--arg2 foo'], noinput=False)

        self.assertSudo('python manage.py test --arg1 234 --arg2 foo',
                        user=DeployUser.sudo_identity())
Beispiel #8
0
    def test_django_manage_simple_command(self):
        django.manage('test')

        self.assertSudo('python manage.py test --noinput',
            user=DeployUser.sudo_identity())
Beispiel #9
0
    def test_django_manage_use_sudo_with_user(self):
        django.manage('test', use_sudo=True, user='******')

        self.assertSudo('python manage.py test --noinput', user='******')
Beispiel #10
0
    def test_django_manage_dont_use_sudo(self):
        django.manage('test', use_sudo=False)

        self.assertRun('python manage.py test --noinput')
Beispiel #11
0
    def test_django_manage_command_with_input(self):
        django.manage('test', ['--arg1 234', '--arg2 foo'], noinput=False)

        self.assertSudo('python manage.py test --arg1 234 --arg2 foo',
            user=DeployUser.sudo_identity())