def do_reset(self, domain):
     if not self.no_input:
         _confirm(
             "This will delete all SQL forms and cases for the domain {}. "
             "Are you sure you want to continue?".format(domain))
     set_couch_sql_migration_not_started(domain)
     blow_away_migration(domain, self.state_dir)
    def handle(self, domain, **options):
        if should_use_sql_backend(domain):
            raise CommandError('It looks like {} has already been migrated.'.format(domain))

        self.no_input = options.pop('no_input', False)
        self.debug = options.pop('debug', False)
        self.dry_run = options.pop('dry_run', False)

        if self.no_input and not settings.UNIT_TESTING:
            raise CommandError('no-input only allowed for unit testing')

        setup_logging(options['log_dir'])
        if options['MIGRATE']:
            self.require_only_option('MIGRATE', options)

            if options.get('run_timestamp'):
                if not couch_sql_migration_in_progress(domain):
                    raise CommandError("Migration must be in progress if run_timestamp is passed in")
            else:
                set_couch_sql_migration_started(domain, self.dry_run)

            do_couch_to_sql_migration(
                domain,
                with_progress=not self.no_input,
                debug=self.debug,
                run_timestamp=options.get('run_timestamp'))

            has_diffs = self.print_stats(domain, short=True, diffs_only=True)
            if has_diffs:
                print("\nUse '--stats-short', '--stats-long', '--show-diffs' to see more info.\n")

        if options['blow_away']:
            self.require_only_option('blow_away', options)
            if not self.no_input:
                _confirm(
                    "This will delete all SQL forms and cases for the domain {}. "
                    "Are you sure you want to continue?".format(domain)
                )
            set_couch_sql_migration_not_started(domain)
            blow_away_migration(domain)

        if options['stats_short'] or options['stats_long']:
            self.print_stats(domain, short=options['stats_short'])
        if options['show_diffs']:
            self.show_diffs(domain)

        if options['COMMIT']:
            self.require_only_option('COMMIT', options)
            if not couch_sql_migration_in_progress(domain, include_dry_runs=False):
                raise CommandError("cannot commit a migration that is not in state in_progress")
            if not self.no_input:
                _confirm(
                    "This will convert the domain to use the SQL backend and"
                    "allow new form submissions to be processed. "
                    "Are you sure you want to do this for domain '{}'?".format(domain)
                )
            set_couch_sql_migration_complete(domain)
示例#3
0
    def handle_label(self, domain, **options):
        if should_use_sql_backend(domain):
            raise CommandError(
                u'It looks like {} has already been migrated.'.format(domain))

        self.no_input = options.pop('no_input', False)
        self.debug = options.pop('debug', False)
        if self.no_input and not settings.UNIT_TESTING:
            raise CommandError('no-input only allowed for unit testing')

        if options['MIGRATE']:
            self.require_only_option('MIGRATE', options)
            set_couch_sql_migration_started(domain)
            do_couch_to_sql_migration(domain,
                                      with_progress=not self.no_input,
                                      debug=self.debug)
            has_diffs = self.print_stats(domain, short=True, diffs_only=True)
            if has_diffs:
                print "\nUse '--stats-short', '--stats-long', '--show-diffs' to see more info.\n"
        if options['blow_away']:
            self.require_only_option('blow_away', options)
            if not self.no_input:
                _confirm(
                    "This will delete all SQL forms and cases for the domain {}. "
                    "Are you sure you want to continue?".format(domain))
            set_couch_sql_migration_not_started(domain)
            _blow_away_migration(domain)
        if options['stats_short'] or options['stats_long']:
            self.print_stats(domain, short=options['stats_short'])
        if options['show_diffs']:
            self.show_diffs(domain)
        if options['COMMIT']:
            self.require_only_option('COMMIT', options)
            assert couch_sql_migration_in_progress(domain)
            if not self.no_input:
                _confirm(
                    "This will allow convert the domain to use the SQL backend and"
                    "allow new form submissions to be processed. "
                    "Are you sure you want to do this for domain '{}'?".format(
                        domain))
            set_couch_sql_migration_complete(domain)
示例#4
0
    def handle_label(self, domain, **options):
        if should_use_sql_backend(domain):
            raise CommandError(u'It looks like {} has already been migrated.'.format(domain))

        self.no_input = options.pop('no_input', False)
        self.debug = options.pop('debug', False)
        if self.no_input and not settings.UNIT_TESTING:
            raise CommandError('no-input only allowed for unit testing')

        if options['MIGRATE']:
            self.require_only_option('MIGRATE', options)
            set_couch_sql_migration_started(domain)
            do_couch_to_sql_migration(domain, with_progress=not self.no_input, debug=self.debug)
            has_diffs = self.print_stats(domain, short=True, diffs_only=True)
            if has_diffs:
                print "\nUse '--stats-short', '--stats-long', '--show-diffs' to see more info.\n"
        if options['blow_away']:
            self.require_only_option('blow_away', options)
            if not self.no_input:
                _confirm(
                    "This will delete all SQL forms and cases for the domain {}. "
                    "Are you sure you want to continue?".format(domain)
                )
            set_couch_sql_migration_not_started(domain)
            _blow_away_migration(domain)
        if options['stats_short'] or options['stats_long']:
            self.print_stats(domain, short=options['stats_short'])
        if options['show_diffs']:
            self.show_diffs(domain)
        if options['COMMIT']:
            self.require_only_option('COMMIT', options)
            assert couch_sql_migration_in_progress(domain)
            if not self.no_input:
                _confirm(
                    "This will allow convert the domain to use the SQL backend and"
                    "allow new form submissions to be processed. "
                    "Are you sure you want to do this for domain '{}'?".format(domain)
                )
            set_couch_sql_migration_complete(domain)
 def abort(self, domain):
     set_couch_sql_migration_not_started(domain)
     clear_local_domain_sql_backend_override(domain)
     _blow_away_migration(domain)
示例#6
0
 def _sigterm_handler(signal, frame):
     _logger.error("{} signal received".format(signal))
     set_couch_sql_migration_not_started(domain)
     clear_local_domain_sql_backend_override(domain)
     _blow_away_migration(domain)
     sys.exit(1)
 def abort(self, domain):
     set_couch_sql_migration_not_started(domain)
     clear_local_domain_sql_backend_override(domain)
     _blow_away_migration(domain)