Esempio n. 1
0
    def migrate(self):
        # disable onupdate for attachment lastmod timestamp
        # see https://bitbucket.org/zzzeek/sqlalchemy/issue/3471/ why it's needed
        Attachment.__table__.columns.modified_dt.onupdate = None
        janitor_user = User.get_one(self.janitor_user_id)
        self.print_msg('Using janitor user {}'.format(janitor_user), always=True)
        self.janitor_user_id = janitor_user.id
        self.todo = OrderedDict([
            (AttachmentFolder, []),
            (AttachmentFolderPrincipal, []),
            (Attachment, []),
            (AttachmentPrincipal, []),
            (AttachmentFile, []),
            (LegacyAttachmentFolderMapping, []),
            (LegacyAttachmentMapping, [])
        ])
        self.ids = {
            AttachmentFolder: _get_pg_id(AttachmentFolder.id),
            Attachment: _get_pg_id(Attachment.id),
            AttachmentFile: _get_pg_id(AttachmentFile.id),
        }
        with patch_default_group_provider(self.default_group_provider):
            self.migrate_category_attachments()
            self.migrate_event_attachments()

        self.fix_attachment_file_ids()
        self.print_step('fixing id sequences')
        self.fix_sequences('attachments')
        self.update_merged_ids()
Esempio n. 2
0
 def migrate(self):
     # disable onupdate for attachment lastmod timestamp
     # see https://bitbucket.org/zzzeek/sqlalchemy/issue/3471/ why it's needed
     Attachment.__table__.columns.modified_dt.onupdate = None
     janitor_user = User.get_one(self.janitor_user_id)
     self.print_msg('Using janitor user {}'.format(janitor_user),
                    always=True)
     self.janitor_user_id = janitor_user.id
     self.todo = OrderedDict([(AttachmentFolder, []),
                              (AttachmentFolderPrincipal, []),
                              (Attachment, []), (AttachmentPrincipal, []),
                              (AttachmentFile, []),
                              (LegacyAttachmentFolderMapping, []),
                              (LegacyAttachmentMapping, [])])
     self.ids = {
         AttachmentFolder: _get_pg_id(AttachmentFolder.id),
         Attachment: _get_pg_id(Attachment.id),
         AttachmentFile: _get_pg_id(AttachmentFile.id),
     }
     with patch_default_group_provider(self.default_group_provider):
         self.migrate_category_attachments()
         self.migrate_event_attachments()
     self.print_step('fixing id sequences')
     self.fix_sequences('attachments')
     self.update_merged_ids()
Esempio n. 3
0
 def migrate(self):
     self.domain_mapping = {
         ipng.name.lower(): ipng
         for ipng in IPNetworkGroup.query
     }
     with patch_default_group_provider(self.default_group_provider):
         self.migrate_categories()
     self.fix_sequences('categories', {'categories'})
Esempio n. 4
0
    def migrate(self):
        self.domains_map = {ipng.name.lower(): ipng for ipng in IPNetworkGroup.query}
        all_users_query = User.query.options(joinedload('_all_emails')).filter_by(is_deleted=False)
        for user in all_users_query:
            for email in user.all_emails:
                self.all_users_by_email[email] = user

        with patch_default_group_provider(self.default_group_provider):
            self.migrate_event_acls()
Esempio n. 5
0
    def migrate(self):
        self.domains_map = {
            ipng.name.lower(): ipng
            for ipng in IPNetworkGroup.query
        }
        all_users_query = User.query.options(
            joinedload('_all_emails')).filter_by(is_deleted=False)
        for user in all_users_query:
            for email in user.all_emails:
                self.all_users_by_email[email] = user

        with patch_default_group_provider(self.default_group_provider):
            self.migrate_event_acls()
Esempio n. 6
0
    def migrate(self):
        self.janitor = User.get_one(self.janitor_user_id)
        # keep all users in memory to avoid extra queries.
        # the assignment is on purpose to stop the gc from throwing the dict away
        # immediately after retrieving it
        _all_users = User.query.options(joinedload('_all_emails')).all()
        self.all_users_by_email = {}
        for user in _all_users:
            if user.is_deleted:
                continue
            for email in user.all_emails:
                self.all_users_by_email[email] = user

        with patch_default_group_provider(self.default_group_provider):
            with db.session.no_autoflush:
                self.migrate_event_managers()
Esempio n. 7
0
    def migrate(self):
        self.janitor = User.get_one(self.janitor_user_id)
        # keep all users in memory to avoid extra queries.
        # the assignment is on purpose to stop the gc from throwing the dict away
        # immediately after retrieving it
        _all_users = User.query.options(joinedload('_all_emails')).all()
        self.all_users_by_email = {}
        for user in _all_users:
            if user.is_deleted:
                continue
            for email in user.all_emails:
                self.all_users_by_email[email] = user

        with patch_default_group_provider(self.default_group_provider):
            with db.session.no_autoflush:
                self.migrate_event_managers()
Esempio n. 8
0
 def migrate(self):
     self.domain_mapping = {ipng.name.lower(): ipng for ipng in IPNetworkGroup.query}
     with patch_default_group_provider(self.default_group_provider):
         self.migrate_categories()
     self.fix_sequences('categories', {'categories'})