equal
deleted
inserted
replaced
382 """ Add eid sequence to a particular etype table and |
382 """ Add eid sequence to a particular etype table and |
383 remove all indexes for performance sake """ |
383 remove all indexes for performance sake """ |
384 if etype not in self._entities: |
384 if etype not in self._entities: |
385 # Only for non-initialized etype and not slave mode store |
385 # Only for non-initialized etype and not slave mode store |
386 if not self.slave_mode: |
386 if not self.slave_mode: |
387 if self.eids_seq_range is None: |
|
388 # Eids are directly set by the entities_id_seq. |
|
389 # We attach this sequence to all the created etypes. |
|
390 sql = ("ALTER TABLE cw_%s ALTER COLUMN cw_eid " |
|
391 "SET DEFAULT nextval('entities_id_seq')" % etype.lower()) |
|
392 self.sql(sql) |
|
393 # Drop indexes and constraints |
387 # Drop indexes and constraints |
394 tablename = 'cw_%s' % etype.lower() |
388 tablename = 'cw_%s' % etype.lower() |
395 self.drop_and_store_indexes(tablename) |
389 self.drop_and_store_indexes(tablename) |
396 # Push the etype in the initialized table for easier restart |
390 # Push the etype in the initialized table for easier restart |
397 self.init_create_initialized_table() |
391 self.init_create_initialized_table() |
436 if 'creation_date' not in kwargs: |
430 if 'creation_date' not in kwargs: |
437 kwargs['creation_date'] = self._now |
431 kwargs['creation_date'] = self._now |
438 if 'cwuri' not in kwargs: |
432 if 'cwuri' not in kwargs: |
439 kwargs['cwuri'] = self._default_cwuri + str(self._count_cwuri) |
433 kwargs['cwuri'] = self._default_cwuri + str(self._count_cwuri) |
440 self._count_cwuri += 1 |
434 self._count_cwuri += 1 |
441 if 'eid' not in kwargs and self.eids_seq_range is not None: |
435 if 'eid' not in kwargs: |
442 # If eid is not given and the eids sequence is set, |
436 # If eid is not given and the eids sequence is set, |
443 # use the value from the sequence |
437 # use the value from the sequence |
444 kwargs['eid'] = self.get_next_eid() |
438 kwargs['eid'] = self.get_next_eid() |
445 self._apply_default_values(etype, kwargs) |
439 self._apply_default_values(etype, kwargs) |
446 self._data_entities[etype].append(kwargs) |
440 self._data_entities[etype].append(kwargs) |
596 sql = 'INSERT INTO cwmassive_metadata VALUES (%(e)s)' |
590 sql = 'INSERT INTO cwmassive_metadata VALUES (%(e)s)' |
597 self.sql(sql, {'e': etype}) |
591 self.sql(sql, {'e': etype}) |
598 |
592 |
599 def _cleanup_entities(self, etype): |
593 def _cleanup_entities(self, etype): |
600 """ Cleanup etype table """ |
594 """ Cleanup etype table """ |
601 if self.eids_seq_range is None: |
|
602 # Remove DEFAULT eids sequence if added |
|
603 sql = 'ALTER TABLE cw_%s ALTER COLUMN cw_eid DROP DEFAULT;' % etype.lower() |
|
604 self.sql(sql) |
|
605 # Create indexes and constraints |
595 # Create indexes and constraints |
606 tablename = SQL_PREFIX + etype.lower() |
596 tablename = SQL_PREFIX + etype.lower() |
607 self.reapply_constraint_index(tablename) |
597 self.reapply_constraint_index(tablename) |
608 |
598 |
609 def _cleanup_relations(self, rtype): |
599 def _cleanup_relations(self, rtype): |