cancel
Showing results for 
Search instead for 
Did you mean: 

SQL anywhere 12-mobilink- START SYNCHRONIZATION SCHEMA CHANGE - Alter publication Add Table Fails...

Former Member
3,450

Hi,

I've been struggling with adding tables to an existing publication.

I'm constantly getting the following message... "This operation is only allowed within a synchronization schema change " http://dcx.sybase.com/index.html#1201/en/saerrors/errm1329.html

I' using SQL Anywhere 12... This must be some sort of security setting I'm sure... Just don't know what I should do in order to fix it...

for adding columns I'm using the following command: "START SYNCHRONIZATION SCHEMA CHANGE", But here I have to specify the tables so for adding columns this works perfectly... but adding new tables... wouldn't know how to handle it...

any tips are welcome !

EDIT: In previous version SQL Anywhere 11, this error would not occur (I can see this in legacy code). Also in order to add columns the "Drop publication" command would be used. I've tried this, but getting the same error.... But when looking at the following thread, the accepted answer says this should still be possible in sql anywhere 12....

http://sqlanywhere-forum.sap.com/questions/9479/fail-to-change-column-type-in-sybase-central-sqlanyw...

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

Okey,

I think I know what's happening after a few tests....

For some reason SQL anywhere considers a foreign key as a modification and complains with the following error: "This operation is only allowed within a synchronization schema change "

So the only way to make this work is to first add the tables to the remote database without foreign keys, then add them to the publications and afterwards add the foreign keys to the tables.....

Unfortunately for me this is turning in to a near nightmare scenario since I'm using Microsoft Entity Framework to generate upgrade scripts....

Breck_Carter
Participant

Does the table exist on the remote database, and you are merely adding it to the publication?

Or are you both creating the table on the remote, AND adding it to the publication? The CREATE is a schema change, the other is an alteration to a publication, two different concepts.

As far as "generating upgrade scripts" via mechanized tools is concerned, that may not be a good idea... every upgrade will be different, and the amount of rote coding work is very small compared to the design and testing effort. In other words, write the upgrade code manually... mechanized tools are only good for rote coding, they cannot think for you.

Former Member
0 Kudos

I'm doing both.

Create the table =>this works

alter publication (add the table to publication) => this only works if there is no foreign key to a newly created table...


in order to reproduce, we need to create 2 tables, with 1 table having a foreign key to the other new table.

Then (after creation) add both to the publication => FAIL

--

I cannot pinpoint the exact cause... But If I have to guess, I think that when these scripts execute inside 1 and the same open database connection, somehow SQL Anywhere gets a bit confused and thinks that the foreign key constraint should be inside a "Synchronization schema change"...

Entity framework just generates the "Create Table" + "Add Column" + "add foreign/primary keys..." etc...

updates to publications I add manually since "Entity framework" knows nothing of synchronization...

But I think Entity framework just runs all queries in 1 open connection... And now by creating a seperate Upgrade script I create a workaround for this problem....

Former Member
0 Kudos

PS. I tried to add a "commit;" statement in between the creation of tables and adding tables to publication but no luck... will have to continue with my elaborate workaround

VolkerBarth
Contributor

FWIW, even the builtin unload/reload tools are known to separate the creation of a table and its FKs, i.e. the FKs are typically created in a delayed fashion with separate ALTER TABLE statements. There are some performance advantages to do so, as Ivan has explained in detail here...

Note, that's not meant as an answer to your requirement (and it surely is none), it may just give a hint as why ML does treat FKs that (at least surprising) way...