[repository] Drop the entities.asource column
It not used anymore thanks to previous patches.
Closes #15538288
--- a/cubicweb/dataimport/massive_store.py Thu Sep 29 22:54:26 2016 +0200
+++ b/cubicweb/dataimport/massive_store.py Fri Sep 30 17:38:12 2016 +0200
@@ -303,10 +303,10 @@
for parent_eschema in chain(eschema.ancestors(), [eschema]):
self._insert_meta_relation(etype, parent_eschema.eid, 'is_instance_of_relation')
# finally insert records into the entities table
- self.sql("INSERT INTO entities (eid, type, asource, extid) "
- "SELECT cw_eid, '%s', '%s', extid FROM cw_%s "
+ self.sql("INSERT INTO entities (eid, type, extid) "
+ "SELECT cw_eid, '%s', extid FROM cw_%s "
"WHERE NOT EXISTS (SELECT 1 FROM entities WHERE eid=cw_eid)"
- % (etype, self.metagen.source.uri, etype.lower()))
+ % (etype, etype.lower()))
def _insert_meta_relation(self, etype, eid_to, rtype):
self.sql("INSERT INTO %s (eid_from, eid_to) SELECT cw_eid, %s FROM cw_%s "
--- a/cubicweb/dataimport/pgstore.py Thu Sep 29 22:54:26 2016 +0200
+++ b/cubicweb/dataimport/pgstore.py Fri Sep 30 17:38:12 2016 +0200
@@ -403,9 +403,6 @@
self._sql_entities[sql].append(attrs)
def _handle_insert_entity_sql(self, cnx, sql, attrs):
- # We have to overwrite the source given in parameters
- # as here, we directly use the system source
- attrs['asource'] = self.system_source.uri
self._sql_eids[sql].append(attrs)
def _handle_is_relation_sql(self, cnx, sql, attrs):
@@ -426,8 +423,7 @@
if extid is not None:
assert isinstance(extid, binary_type)
extid = b64encode(extid).decode('ascii')
- attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid,
- 'asource': source.uri}
+ attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid}
self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
# insert core relations: is, is_instance_of and cw_source
self._handle_is_relation_sql(cnx, 'INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)',
--- a/cubicweb/hooks/metadata.py Thu Sep 29 22:54:26 2016 +0200
+++ b/cubicweb/hooks/metadata.py Fri Sep 30 17:38:12 2016 +0200
@@ -194,8 +194,7 @@
syssource = newsource.repo_source
oldsource = self._cw.entity_from_eid(schange[self.eidfrom])
entity = self._cw.entity_from_eid(self.eidfrom)
- attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': None,
- 'asource': 'system'}
+ attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': None}
self._cw.system_sql(syssource.sqlgen.update('entities', attrs, ['eid']), attrs)
# register an operation to update repository/sources caches
ChangeEntitySourceUpdateCaches(self._cw, entity=entity,
--- a/cubicweb/hooks/syncsources.py Thu Sep 29 22:54:26 2016 +0200
+++ b/cubicweb/hooks/syncsources.py Fri Sep 30 17:38:12 2016 +0200
@@ -92,12 +92,6 @@
class SourceRenamedOp(hook.LateOperation):
oldname = newname = None # make pylint happy
- def precommit_event(self):
- source = self.cnx.repo.sources_by_uri[self.oldname]
- sql = 'UPDATE entities SET asource=%(newname)s WHERE asource=%(oldname)s'
- self.cnx.system_sql(sql, {'oldname': self.oldname,
- 'newname': self.newname})
-
def postcommit_event(self):
repo = self.cnx.repo
# XXX race condition
--- a/cubicweb/misc/migration/3.24.0_Any.py Thu Sep 29 22:54:26 2016 +0200
+++ b/cubicweb/misc/migration/3.24.0_Any.py Fri Sep 30 17:38:12 2016 +0200
@@ -4,3 +4,4 @@
ask_confirm=False)
sql('DROP TABLE moved_entities')
+sql('ALTER TABLE entities DROP COLUMN asource')
--- a/cubicweb/misc/migration/bootstrapmigration_repository.py Thu Sep 29 22:54:26 2016 +0200
+++ b/cubicweb/misc/migration/bootstrapmigration_repository.py Fri Sep 30 17:38:12 2016 +0200
@@ -54,23 +54,6 @@
cursor.execute(dbh.sql_restart_numrange('entities_id_seq', initial_value=lasteid))
session.commit()
-if applcubicwebversion <= (3, 13, 0) and cubicwebversion >= (3, 13, 1):
- sql('ALTER TABLE entities ADD asource VARCHAR(64)')
- sql('UPDATE entities SET asource=cw_name '
- 'FROM cw_CWSource, cw_source_relation '
- 'WHERE entities.eid=cw_source_relation.eid_from AND cw_source_relation.eid_to=cw_CWSource.cw_eid')
- commit()
-
-if applcubicwebversion <= (3, 14, 4) and cubicwebversion >= (3, 14, 4):
- from cubicweb.server import schema2sql as y2sql
- dbhelper = repo.system_source.dbhelper
- rdefdef = schema['CWSource'].rdef('name')
- attrtype = y2sql.type_from_constraints(dbhelper, rdefdef.object, rdefdef.constraints).split()[0]
- cursor = session.cnxset.cu
- sql('UPDATE entities SET asource = source WHERE asource is NULL')
- dbhelper.change_col_type(cursor, 'entities', 'asource', attrtype, False)
- dbhelper.change_col_type(cursor, 'entities', 'source', attrtype, False)
-
if applcubicwebversion < (3, 19, 0) and cubicwebversion >= (3, 19, 0):
try:
# need explicit drop of the indexes on some database systems (sqlserver)
--- a/cubicweb/server/sources/native.py Thu Sep 29 22:54:26 2016 +0200
+++ b/cubicweb/server/sources/native.py Fri Sep 30 17:38:12 2016 +0200
@@ -843,8 +843,7 @@
if extid is not None:
assert isinstance(extid, binary_type)
extid = b64encode(extid).decode('ascii')
- attrs = {'type': text_type(entity.cw_etype), 'eid': entity.eid, 'extid': extid,
- 'asource': text_type(source.uri)}
+ attrs = {'type': text_type(entity.cw_etype), 'eid': entity.eid, 'extid': extid}
self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
# insert core relations: is, is_instance_of and cw_source
@@ -1334,7 +1333,6 @@
CREATE TABLE entities (
eid INTEGER PRIMARY KEY NOT NULL,
type VARCHAR(64) NOT NULL,
- asource VARCHAR(128) NOT NULL,
extid VARCHAR(256)
);;
CREATE INDEX entities_type_idx ON entities(type);;
--- a/cubicweb/server/test/unittest_repository.py Thu Sep 29 22:54:26 2016 +0200
+++ b/cubicweb/server/test/unittest_repository.py Fri Sep 30 17:38:12 2016 +0200
@@ -442,7 +442,7 @@
self.repo.add_info(cnx, entity, self.repo.system_source)
cu = cnx.system_sql('SELECT * FROM entities WHERE eid = -1')
data = cu.fetchall()
- self.assertEqual(tuplify(data), [(-1, 'Personne', 'system', None)])
+ self.assertEqual(tuplify(data), [(-1, 'Personne', None)])
self.repo._delete_cascade_multi(cnx, [entity])
self.repo.system_source.delete_info_multi(cnx, [entity])
cu = cnx.system_sql('SELECT * FROM entities WHERE eid = -1')