Mailing List Archive

bric_soap export & create issues
Hi,
I want to transfer some stories from a devel instance (11.2) to
another devel instance (11.3) and have some problems.
I run
bric_soap story export --all 1024 >story_1024.xml
bric_soap story create --server serverB story_1024.xml

If story 1024 has been published on serverA then I get an sql error

ERROR: new row for relation "story" violates check constraint
"ck_story__publish_status"
[.for Statement "INSERT INTO story (id, uuid, priority, source__id,
usr__id, element_type__id, first_publish_date, publish_date,
expire_date, current_version, published_version, workflow__id,
publish_status, primary_uri, active, desk__id, site__id, alias_id)
VALUES (NEXTVAL('seq_story'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?)" with ParamValues:
1='2E4CD37E-2708-11DF-8B60-A09EE39715BC', 2='3', 3='1', 4='0',
5='1060', 6='2010-01-18 10:23:27.000000', 7='2010-01-18
10:23:27.000000', 8='2010-03-03 21:03:13.000000', 9='0', 10=undef,
11='0', 12='0', 13='/ui/inc/site_php_include_main/', 14='0', 15='0',
16='100', 17=undef] at /usr/local/bricolage/lib/Bric/Util/DBI.pm line
1138, etc.


I suspect that I should modify xml before bric_soap create (correct me please):
set publish_status -> 0
and remove first_publish_date, publish_date tags
(anything else?)

If a story has not been published before no error occures unless a
story has media related.
In this case I get an sql error:
ERROR: insert or update on table "media_element" violates foreign key
constraint "fk_media_element__related_media"\nDETAIL: Key
(related_media__id)=(1052) is not present in table "media". [.for
Statement "\n UPDATE media_element\n SET
element_type__id = ?, object_instance_id = ?, parent_id = ?, place =
?, object_order = ?, displayed = ?, related_story__id = ?,
related_media__id = ?, active = ?\n WHERE id = ?\n " with
ParamValues: 1='1071', 2='1025', 3=undef, 4='0', 5='1', 6='0',
7=undef, 8='1052', 9='1', 10='1025']

Both story and related media has been created on server B but a
relation hasn't been established.

The last strange thing is that all stories (published or unpublished
on serverA) created
via bric_soap on serverB have published_version=1 just after creation.

I tried to digg bric list archive but couldn't find anything that could help me.

Could anybody help me, please
Krzysztof
Re: bric_soap export & create issues [ In reply to ]
On Mar 23, 2010, at 4:03 PM, Krzysztof Rudnik wrote:

> I suspect that I should modify xml before bric_soap create (correct me please):
> set publish_status -> 0
> and remove first_publish_date, publish_date tags
> (anything else?)

Not quite. What I've done when migrating clients is to modify this code in Bric::SOAP::Story:

if ($update) {
if ($story->get_publish_date or $story->get_first_publish_date) {
# some publish date is set, so it must've been published
$story->set_publish_status(1);
} else {
$story->set_publish_status($sdata->{publish_status});
}
} else {
# creating, so can't have published it yet
$story->set_publish_status(0);
}

Simplest thing to do is to change `if ($update) {` to `if (1) {`. That will allow you to keep whatever publish status you had on the other server.

Unless of course you don't care, in which case remove the publish_date and first_publish_date from the XML before you import it.

> If a story has not been published before no error occures unless a
> story has media related.
> In this case I get an sql error:
> ERROR: insert or update on table "media_element" violates foreign key
> constraint "fk_media_element__related_media"\nDETAIL: Key
> (related_media__id)=(1052) is not present in table "media". [.for
> Statement "\n UPDATE media_element\n SET
> element_type__id = ?, object_instance_id = ?, parent_id = ?, place =
> ?, object_order = ?, displayed = ?, related_story__id = ?,
> related_media__id = ?, active = ?\n WHERE id = ?\n " with
> ParamValues: 1='1071', 2='1025', 3=undef, 4='0', 5='1', 6='0',
> 7=undef, 8='1052', 9='1', 10='1025']
>
> Both story and related media has been created on server B but a
> relation hasn't been established.

Yes, you need to establish the relationship. You can do this if the story and media document are int the same XML file. IIRC, Bricolage will in that case do the right thing. You can export related media along with a story from server A by passing --with-related-media (or --all to also included related stories) to bric_soap.

> The last strange thing is that all stories (published or unpublished
> on serverA) created
> via bric_soap on serverB have published_version=1 just after creation.

Hrm. That's odd. That shouldn't happen at all, as there is a constraint to prevent published_version from being set unless publish_status is true. Hrm…or maybe there isn't. There ought to be. In any event, it *should* be null for all those stories. You're not piping them to `bric_soap workflow publish`, are you?

HTH,

David
Re: bric_soap export & create issues [ In reply to ]
On Wed, Mar 24, 2010 at 3:17 AM, David E. Wheeler <david@kineticode.com> wrote:
> On Mar 23, 2010, at 4:03 PM, Krzysztof Rudnik wrote:
>
>> I suspect that I should modify xml before bric_soap create (correct me please):
>> set publish_status -> 0
>> and remove first_publish_date, publish_date tags
>> (anything else?)
>
> Not quite. What I've done when migrating clients is to modify this code in Bric::SOAP::Story:
>
>        if ($update) {
>            if ($story->get_publish_date or $story->get_first_publish_date) {
>                # some publish date is set, so it must've been published
>                $story->set_publish_status(1);
>            } else {
>                $story->set_publish_status($sdata->{publish_status});
>            }
>        } else {
>            # creating, so can't have published it yet
>            $story->set_publish_status(0);
>        }
>
> Simplest thing to do is to change `if ($update) {` to `if (1) {`. That will allow you to keep whatever publish status you had on the other server.
thanks. that is clear

>
> Unless of course you don't care, in which case remove the publish_date and first_publish_date from the XML before you import it.
>
>> If a story has not been published before no error occures  unless a
>> story has media related.
>> In this case I get an sql error:
>> ERROR:  insert or update on table "media_element" violates foreign key
>> constraint "fk_media_element__related_media"\nDETAIL:  Key
>> (related_media__id)=(1052) is not present in table "media". [.for
>> Statement "\n        UPDATE media_element\n        SET
>> element_type__id = ?, object_instance_id = ?, parent_id = ?, place =
>> ?, object_order = ?, displayed = ?, related_story__id = ?,
>> related_media__id = ?, active = ?\n        WHERE  id = ?\n    " with
>> ParamValues: 1='1071', 2='1025', 3=undef, 4='0', 5='1', 6='0',
>> 7=undef, 8='1052', 9='1', 10='1025']
>>
>> Both story and related media has been created on server B but a
>> relation hasn't been established.
>
> Yes, you need to establish the relationship. You can do this if the story and media document
> are int the same XML file. IIRC, Bricolage will in that case do the right thing. You can export
> related media along with a story from server A by passing --with-related-media (or --all to also
> included related stories) to bric_soap.
But I've passed --all and media doc is embeded in story xml file.
During bric_soap story create the above error message appears
and both story and embeded related media get created (witht no
relationship established)



>
>> The last strange thing is that all stories (published or unpublished
>> on serverA) created
>> via bric_soap on serverB have published_version=1 just after creation.
>
> Hrm. That's odd. That shouldn't happen at all, as there is a constraint to prevent published_version from being set unless publish_status is true. Hrm…or maybe there isn't. There ought to be. In any event, it *should* be null for all those stories. You're not piping them to `bric_soap workflow publish`, are you?
no certainly not.
>
> HTH,
>
> David
thanks
Krzysztof

>
>
Re: bric_soap export & create issues [ In reply to ]
On Mar 24, 2010, at 5:19 AM, Krzysztof Rudnik wrote:

> But I've passed --all and media doc is embeded in story xml file.
> During bric_soap story create the above error message appears
> and both story and embeded related media get created (witht no
> relationship established)

Hrm. Do the related media elements have a "relative" key in the XML?

Best,

David
Re: bric_soap export & create issues [ In reply to ]
On Thu, Mar 25, 2010 at 3:08 AM, David E. Wheeler <david@kineticode.com> wrote:
> On Mar 24, 2010, at 5:19 AM, Krzysztof Rudnik wrote:
>
>> But  I've passed  --all and media doc is embeded  in story xml file.
>> During  bric_soap story create the above error message appears
>> and both story and embeded related media get created (witht no
>> relationship established)
>
> Hrm. Do the related media elements have a "relative" key in the XML?
Well, I can't replicate this now
New stories migrate with no problems.
I'll look at what I was doing carefully.
Thanks
Krzysztof

>
> Best,
>
> David
>
>