Issue 84 in contentmirror: In the SQL file generation the autoincrement of field "content_id" is missing!

0 views
Skip to first unread message

conten...@googlecode.com

unread,
Jun 29, 2013, 1:42:23 PM6/29/13
to conten...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 84 by develo...@acsr.de: In the SQL file generation the
autoincrement of field "content_id" is missing!
http://code.google.com/p/contentmirror/issues/detail?id=84

Export schema of Plone for new database
===========================================

Symptom
--------------------------

With the default sql file generated by mirror-ddl command, adding a lot of
real content in Plone does not increment the field "content_id" of all the
tables generated using this file. So you end up with overwriting existing
entries in the RDBMS instead of adding new ones.

Case
------------------

Due to a bug in the SQL file generation the autoincrement of
field "content_id" is missing!

Currently we manage this by postprocessing the sql file with sed.

Procedures see below.

Solution ?
---------------------

No idea where to fix.


Procedures to reproduce and workaround
===========================================

Using the default ore.contentmirror configuration only for Plone
---------------------------------------------------------------------------------

* file ore.contentmirror/ore/contentmirror/content.zcml

```
#!python

<configure xmlns="http://namespaces.zope.org/zope"
xmlns:ore="http://namespaces.objectrealms.net/mirror">
<ore:mirror
content="Products.ATContentTypes.content.document.ATDocument" />
<ore:mirror content="Products.ATContentTypes.content.event.ATEvent"
/>
<ore:mirror
content="Products.ATContentTypes.content.favorite.ATFavorite" />
<ore:mirror content="Products.ATContentTypes.content.file.ATFile" />
<ore:mirror
content="Products.ATContentTypes.content.folder.ATFolder" />
<ore:mirror
content="Products.ATContentTypes.content.folder.ATBTreeFolder" />
<ore:mirror content="Products.ATContentTypes.content.image.ATImage"
/>
<ore:mirror content="Products.ATContentTypes.content.link.ATLink" />
<ore:mirror
content="Products.ATContentTypes.content.newsitem.ATNewsItem" />
</configure>
```

* At the instance root run command::


```
#!bash
./bin/instance run ./bin/mirror-ddl mysql
> ./Plone-mysql-schema-temp.sql
```
#### IMPORTANT ####

* Use droptables option -d only when wiping out existing data!

```
#!bash
./bin/instance run ./bin/mirror-ddl -d mysql
> ./Plone-mysql-schema-temp.sql
```

Modify SQL file manually
------------------------------

Due to a bug in the SQL file generation the autoincrement of
field "content_id" is missing!

see
http://fatalweb.com/question/contentmirror-integration-with-plone-4-5721836.html

#### Add "Autoincrement" flag ####

Add "Autoincrement" flag to every field "content_id" in every table.

* Change every

```
#!bash
content_id INTEGER NOT NULL,
```

* to

```
#!bash
content_id INTEGER NOT NULL AUTO_INCREMENT,
```

* sed one liner

```
#!bash
sed '/content_id INTEGER NOT NULL,/ s//content_id INTEGER NOT NULL
AUTO_INCREMENT,/g' ./Plone-mysql-schema-temp.sql > ./Plone-mysql-schema.sql
rm ./Plone-mysql-schema-temp.sql
```

Using the special configuration for iwe.projectmag
-------------------------------------------------------

```
#!python

<configure xmlns="http://namespaces.zope.org/zope"
xmlns:ore="http://namespaces.objectrealms.net/mirror">
<ore:mirror
content="Products.ATContentTypes.content.document.ATDocument" />
<ore:mirror content="Products.ATContentTypes.content.event.ATEvent"
/>
<ore:mirror
content="Products.ATContentTypes.content.favorite.ATFavorite" />
<ore:mirror content="Products.ATContentTypes.content.file.ATFile" />
<ore:mirror
content="Products.ATContentTypes.content.folder.ATFolder" />
<ore:mirror
content="Products.ATContentTypes.content.folder.ATBTreeFolder" />
<ore:mirror content="Products.ATContentTypes.content.image.ATImage"
/>
<ore:mirror content="Products.ATContentTypes.content.link.ATLink" />
<ore:mirror
content="Products.ATContentTypes.content.newsitem.ATNewsItem" />
<!-- begin contenttypes from my.package -->
<ore:mirror content="my.package.content.projects.Projects" />
<ore:mirror content="my.package.content.project.Project" />
<ore:mirror content="my.package.content.magazine.Magazine" />
<ore:mirror content="my.package.content.article.Article" />
<ore:mirror content="my.package.content.message.Message" />
<ore:mirror content="my.package.content.vote.Vote" />
<ore:mirror content="my.package.content.shout.Shout" />
<ore:mirror content="my.package.content.shouts.Shouts" />
<!-- end contenttypes from my.package -->
</configure>
```

* At the instance root run command

```
#!bash
./bin/instance run ./bin/mirror-ddl mysql > ./my-mysql-schema-temp.sql
```

#### IMPORTANT ####

* Use droptables option -d only when wiping out existing data!

```
#!bash
./bin/instance run ./bin/mirror-ddl -d mysql
> ./my-mysql-schema-temp.sql
```

* one liner with sed

```
#!bash
./bin/instance run ./bin/mirror-ddl mysql | sed '/content_id INTEGER
NOT NULL,/ s//content_id INTEGER NOT NULL AUTO_INCREMENT,/g'
> ./my-mysql-schema.sql
```


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages