Unable to set up client which is derby and server is mysql
C:\symmetric-ds-3.0.1-server\symmetric-ds-3.0.1\samples>..\bin\dbimport --engine
client1 --format XML create_sample.xml
Log output will be written to ../logs/symmetric.log
[] - AbstractCommandLauncher - Option: name=engine, value={client1}
[] - AbstractCommandLauncher - Option: name=format, value={XML}
[client1] - DerbySymmetricDialect - The DbDialect being used is org.jumpmind.sym
metric.db.derby.DerbySymmetricDialect
[client1] - ExtensionPointManager - Found 2 extension points that will be regist
ered
[client1] - JdbcSqlTemplate - Table/View 'item_selling_price' already exists in
Schema 'SYMMETRIC'.. Failed to execute: CREATE TABLE "item_selling_price"
(
"price_id" INTEGER NOT NULL,
"price" DECIMAL(10,2) NOT NULL,
"cost" DECIMAL(10,2),
PRIMARY KEY ("price_id")
).
[client1] - JdbcSqlTemplate - Table/View 'item' already exists in Schema 'SYMMET
RIC'.. Failed to execute: CREATE TABLE "item"
(
"item_id" INTEGER NOT NULL,
"price_id" INTEGER NOT NULL,
"name" VARCHAR(100),
PRIMARY KEY ("item_id")
).
[client1] - JdbcSqlTemplate - Table/View 'sale_transaction' already exists in Sc
hema 'SYMMETRIC'.. Failed to execute: CREATE TABLE "sale_transaction"
(
"tran_id" INTEGER NOT NULL,
"store" VARCHAR(5) NOT NULL,
"workstation" VARCHAR(3) NOT NULL,
"day" VARCHAR(10) NOT NULL,
"seq" INTEGER NOT NULL,
PRIMARY KEY ("tran_id")
).
[client1] - JdbcSqlTemplate - Table/View 'sale_return_line_item' already exists
in Schema 'SYMMETRIC'.. Failed to execute: CREATE TABLE "sale_return_line_item"
(
"tran_id" INTEGER NOT NULL,
"item_id" INTEGER NOT NULL,
"price" DECIMAL(10,2) NOT NULL,
"quantity" INTEGER NOT NULL,
"returned_quantity" INTEGER,
PRIMARY KEY ("tran_id")
).
[client1] - JdbcSqlTemplate - Table/View 'sale_tender_line_item' already exists
in Schema 'SYMMETRIC'.. Failed to execute: CREATE TABLE "sale_tender_line_item"
(
"tran_id" INTEGER NOT NULL,
"tender_type" VARCHAR(254) NOT NULL,
"tender_amount" DECIMAL(10,2) NOT NULL,
"account_number" VARCHAR(255) NOT NULL,
PRIMARY KEY ("tran_id")
).
[client1] - JdbcSqlTemplate - Constraint 'fk_item_price_id' already exists in Sc
hema 'SYMMETRIC'.. Failed to execute: ALTER TABLE "item"
ADD CONSTRAINT "fk_item_price_id" FOREIGN KEY ("price_id") REFERENCES "item_sell
ing_price" ("price_id").
[client1] - JdbcSqlTemplate - Constraint 'fk_srli_tran_id' already exists in Sch
ema 'SYMMETRIC'.. Failed to execute: ALTER TABLE "sale_return_line_item"
ADD CONSTRAINT "fk_srli_tran_id" FOREIGN KEY ("tran_id") REFERENCES "sale_transa
ction" ("tran_id").
[client1] - JdbcSqlTemplate - Constraint 'fk_srli_item_id' already exists in Sch
ema 'SYMMETRIC'.. Failed to execute: ALTER TABLE "sale_return_line_item"
ADD CONSTRAINT "fk_srli_item_id" FOREIGN KEY ("item_id") REFERENCES "item" ("ite
m_id").
[client1] - JdbcSqlTemplate - Constraint 'fk_tndr_tran_id' already exists in Sch
ema 'SYMMETRIC'.. Failed to execute: ALTER TABLE "sale_tender_line_item"
ADD CONSTRAINT "fk_tndr_tran_id" FOREIGN KEY ("tran_id") REFERENCES "sale_transa
ction" ("tran_id").
C:\symmetric-ds-3.0.1-server\symmetric-ds-3.0.1\samples>
It looks like you're trying to create the sample tables that are part of the SymmetricDS Tutorial and the tables already exist in the database. You probably ran the command two times instead of once. The first time you run it, it creates all the tables. The second time you run it, it complains that the tables already exist.
I just ran through the tutorial with SymmetricDS 3.0.10 and I got the sample database to replicate between Apache Derby 10.5.3.0_1 and MySQL 5.5.25a. One thing I noticed is I needed to specify the properties file, like this:
..\bin\dbimport --engine client1 --format XML --properties client.properties create_sample.xml
Without specifying the properties file, I thought I was creating tables on the client, but it was still using the server's properties file, which gave me the same error you got.
Related
I was going through the WSO2 documentation to Monetize an API. In the database configuration section, it has been mentioned that we have to execute the provided database script. If we select Postgres, it displays the script to be executed.
However, all the CREATE TABLE statements have the same table name, even though the sequence names are different. For other databases like MySQL, Oracle, etc, the table names are different as well.
Just to be sure, I even checked with older documentation and it's the same even in older documentation. Script for Postgres database:
CREATE SEQUENCE AM_MONETIZATION START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_POLICY_SUBSCRIPTION (
API_ID INTEGER NOT NULL,
TIER_NAME VARCHAR(512),
STRIPE_PRODUCT_ID VARCHAR(512),
STRIPE_PLAN_ID VARCHAR(512),
FOREIGN KEY (API_ID) REFERENCES AM_API (API_ID) ON DELETE CASCADE
);
CREATE SEQUENCE AM_POLICY_PLAN_MAPPING START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_POLICY_SUBSCRIPTION (
POLICY_ID INTEGER DEFAULT NEXTVAL('AM_POLICY_PLAN_MAPPING'),
POLICY_UUID VARCHAR(256),
PRODUCT_ID VARCHAR(512),
PLAN_ID VARCHAR(512),
FOREIGN KEY (POLICY_UUID) REFERENCES AM_POLICY_SUBSCRIPTION(UUID)
);
CREATE SEQUENCE AM_MONETIZATION_PLATFORM_CUSTOMERS START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_POLICY_SUBSCRIPTION (
POLICY_ID INTEGER DEFAULT NEXTVAL('AM_MONETIZATION_PLATFORM_CUSTOMERS'),
ID INTEGER NOT NULL AUTO_INCREMENT,
SUBSCRIBER_ID INTEGER NOT NULL,
TENANT_ID INTEGER NOT NULL,
CUSTOMER_ID VARCHAR(256) NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON DELETE CASCADE
);
CREATE SEQUENCE AM_MONETIZATION_SHARED_CUSTOMERS START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_POLICY_SUBSCRIPTION (
POLICY_ID INTEGER DEFAULT NEXTVAL('AM_MONETIZATION_SHARED_CUSTOMERS'),
ID INTEGER NOT NULL AUTO_INCREMENT,
APPLICATION_ID INTEGER NOT NULL,
API_PROVIDER VARCHAR(256) NOT NULL,
TENANT_ID INTEGER NOT NULL,
SHARED_CUSTOMER_ID VARCHAR(256) NOT NULL,
PARENT_CUSTOMER_ID INTEGER NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON DELETE CASCADE,
FOREIGN KEY (PARENT_CUSTOMER_ID) REFERENCES AM_MONETIZATION_PLATFORM_CUSTOMERS(ID) ON DELETE CASCADE
);
CREATE SEQUENCE AM_MONETIZATION_SUBSCRIPTIONS START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_POLICY_SUBSCRIPTION (
POLICY_ID INTEGER DEFAULT NEXTVAL('AM_MONETIZATION_SUBSCRIPTIONS'),
ID INTEGER NOT NULL AUTO_INCREMENT,
SUBSCRIBED_APPLICATION_ID INTEGER NOT NULL,
SUBSCRIBED_API_ID INTEGER NOT NULL,
TENANT_ID INTEGER NOT NULL,
SUBSCRIPTION_ID VARCHAR(256) NOT NULL,
SHARED_CUSTOMER_ID INTEGER NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (SUBSCRIBED_APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON DELETE CASCADE,
FOREIGN KEY (SUBSCRIBED_API_ID) REFERENCES AM_API(API_ID) ON DELETE CASCADE,
FOREIGN KEY (SHARED_CUSTOMER_ID) REFERENCES AM_MONETIZATION_SHARED_CUSTOMERS(ID) ON DELETE CASCADE
);
I changed the table names based on what is used in MySQL script and created a Monetization policy. While I try to subscribe an API to the monetized policy, I am getting the following error:
ERROR - StripeMonetizationDAO Failed to add Stripe platform customer details for Subscriber : 1
ERROR - APIConsumerImpl Could not execute Workflow
org.wso2.carbon.apimgt.impl.workflow.WorkflowException: Error when inserting stripe customer details of username to Database
Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "id" violates not-null constraint
Detail: Failing row contains (3, null, 1, -1234, cus_M7MKkaasfCbdf342SEn).
ERROR - GlobalThrowableMapper Could not execute Workflow
I am not sure if the above errors are due to the table name changes in the script or due to the update in workflow executors. I have added the following in workflow executors:
<SubscriptionCreation executor="<billing-engine-related-SubscriptionCreationWorkflowExecutor>"/>
<SubscriptionDeletion executor="<billing-engine-related-StripeSubscriptionDeletionWorkflowExecutor>"/>
There seems to be several issues with the documented db scripts for postgress and seems like we have missed it. Can you try the following scripts. Please note that i haven't tried it in postgress, but fixed multiple schema issues and this should work.
CREATE TABLE IF NOT EXISTS AM_MONETIZATION (
API_ID INTEGER NOT NULL,
TIER_NAME VARCHAR(512),
STRIPE_PRODUCT_ID VARCHAR(512),
STRIPE_PLAN_ID VARCHAR(512),
FOREIGN KEY (API_ID) REFERENCES AM_API (API_ID) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS AM_POLICY_PLAN_MAPPING (
POLICY_UUID VARCHAR(256),
PRODUCT_ID VARCHAR(512),
PLAN_ID VARCHAR(512),
FOREIGN KEY (POLICY_UUID) REFERENCES AM_POLICY_SUBSCRIPTION(UUID)
);
CREATE SEQUENCE AM_MONETIZATION_PLATFORM_CUSTOMERS_SEQ START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_MONETIZATION_PLATFORM_CUSTOMERS (
ID INTEGER DEFAULT NEXTVAL('AM_MONETIZATION_PLATFORM_CUSTOMERS_SEQ'),
SUBSCRIBER_ID INTEGER NOT NULL,
TENANT_ID INTEGER NOT NULL,
CUSTOMER_ID VARCHAR(256) NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON DELETE CASCADE
);
CREATE SEQUENCE AM_MONETIZATION_SHARED_CUSTOMERS_SEQ START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_MONETIZATION_SHARED_CUSTOMERS (
ID INTEGER DEFAULT NEXTVAL('AM_MONETIZATION_SHARED_CUSTOMERS_SEQ'),
APPLICATION_ID INTEGER NOT NULL,
API_PROVIDER VARCHAR(256) NOT NULL,
TENANT_ID INTEGER NOT NULL,
SHARED_CUSTOMER_ID VARCHAR(256) NOT NULL,
PARENT_CUSTOMER_ID INTEGER NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON DELETE CASCADE,
FOREIGN KEY (PARENT_CUSTOMER_ID) REFERENCES AM_MONETIZATION_PLATFORM_CUSTOMERS(ID) ON DELETE CASCADE
);
CREATE SEQUENCE AM_MONETIZATION_SUBSCRIPTIONS_SEQ START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS AM_MONETIZATION_SUBSCRIPTIONS (
ID INTEGER DEFAULT NEXTVAL('AM_MONETIZATION_SUBSCRIPTIONS_SEQ'),
SUBSCRIBED_APPLICATION_ID INTEGER NOT NULL,
SUBSCRIBED_API_ID INTEGER NOT NULL,
TENANT_ID INTEGER NOT NULL,
SUBSCRIPTION_ID VARCHAR(256) NOT NULL,
SHARED_CUSTOMER_ID INTEGER NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (SUBSCRIBED_APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON DELETE CASCADE,
FOREIGN KEY (SUBSCRIBED_API_ID) REFERENCES AM_API(API_ID) ON DELETE CASCADE,
FOREIGN KEY (SHARED_CUSTOMER_ID) REFERENCES AM_MONETIZATION_SHARED_CUSTOMERS(ID) ON DELETE CASCADE
);
I've created a MySQL Model with a few tables, some of them with fk's to another table. I usually export the SQL from MySQL Model to my database using the "Forward Engineer SQL CREATE Script" inside File -> Export -> Forward Engineer SQL CREATE Script. The problem here is that when I generate the creation script, all my fk's become unique. I didn't check UQ option in MySQL Model but it creates a script with unique fk's anyway, so, I need to change the SQL file generated and remove all the unwanted uniques. Anyone has a clue why this is happening?
Generated script:
CREATE TABLE IF NOT EXISTS `u514786799_detranleiloes`.`Lotes` (
`createdAt` DATE NOT NULL,
`updatedAt` DATE NOT NULL,
`id` INT UNIQUE NOT NULL AUTO_INCREMENT,
`LeiloesId` INT UNIQUE NOT NULL,
`conservado` TINYINT NULL,
`numero` INT NOT NULL,
`CRDsId` INT UNIQUE NULL,
PRIMARY KEY (`id`),
INDEX `fk_Lotes_Leiloes_idx` (`LeiloesId` ASC),
INDEX `fk_Lotes_CRDs1_idx` (`CRDsId` ASC),
CONSTRAINT `fk_Lotes_Leiloes`
FOREIGN KEY (`LeiloesId`)
REFERENCES `u514786799_detranleiloes`.`Leiloes` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Lotes_CRDs1`
FOREIGN KEY (`CRDsId`)
REFERENCES `u514786799_detranleiloes`.`CRDs` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 1;
When I create a database dump from Amazon RDS and then I try to import it locally, the result is ERROR 1064 (42000) at line 54.
At line 54 there is the following statement:
CREATE TABLE account_emailconfirmation (
The command used for dump is:
mysqldump -u user -h host.rds.amazonaws.com -p --default-character-set=utf8 --result-file=sync.sql database_name
The command used for import is:
mysql --user=root -p mpl -vv < sync.sql
And here is the output (verbosity increased).
--------------
CREATE TABLE `account_emailconfirmation` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime(6) NOT NULL,
`sent` datetime(6) DEFAULT NULL,
`key` varchar(64) NOT NULL,
`email_address_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `key` (`key`),
KEY `acc_email_address_id_5bcf9f503c32d4d8_fk_account_emailaddress_id` (`email_address_id`),
CONSTRAINT `acc_email_address_id_5bcf9f503c32d4d8_fk_account_emailaddress_id` FOREIGN KEY (`email_address_id`) REFERENCES `account_emailaddress` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
--------------
ERROR 1064 (42000) at line 54: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL,
`sent` datetime(6) DEFAULT NULL,
`key` varchar(64) NOT NULL,
' at line 3
Bye
The problem is with datetime(6). MySql introduced storing of fractional seconds in v5.6.4. The syntax for indicating fractional seconds in datetime - this is the (6) - is not recognised by previous mysql versions.
The data was exported from a mysql v5.6.4 or later, and was attempted to be imported into an earlier version. Since the error message starts with (6), I believe that this is the problem.
'key' is a reserved word in MySQL, and shouldn't be used as a column name. It's possible that a different version on Amazon RDS allowed it, but your best bet is to change the column name to something different.
How to update and set unit_id to be NULL, unit id is foreign key and I need to set to be NULL
CREATE TABLE troops
(
id serial NOT NULL,
unit_id integer,
type integer NOT NULL,
level integer NOT NULL,
CONSTRAINT troops_pkey PRIMARY KEY (id),
CONSTRAINT troops_unit_id_fkey FOREIGN KEY (unit_id)
REFERENCES units (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE
)
WITH (
OIDS=FALSE
);
I have tried to update troops and set unit_id to be NULL ( I put NULL not 0 in pqxx statement in C++ ) but I get error like
insert or update on table "troops" violates foreign key constraint "troops_unit_id_fkey"
DETAIL: Key (unit_id)=(0) is not present in table "units".
When I try from pgadmin I can set unit_id to be NULL in troops but pqxx ( from c++ code I try to update) converts NULL to 0, how to solve this ?
Using django, I added a new entry to my table. Now I want to delete it using PHPPgAdmin (postgresql), but I get No unique Identifier for this row error. What is the problem?
django automatically adds an auto-incrementing primary key, so I cannot figure out what the issue is?
I read this post, but it did not help. If you notice the image carefully, you will see that the primary key column label is id but not pk as it should be in django.
EDIT: No primary key is seen on table;
But this is what django executes;
python manage.py sql auth
CREATE TABLE "auth_user" (
"id" serial NOT NULL PRIMARY KEY,
"password" varchar(128) NOT NULL,
"last_login" timestamp with time zone NOT NULL,
"is_superuser" boolean NOT NULL,
"username" varchar(30) NOT NULL UNIQUE,
"first_name" varchar(30) NOT NULL,
"last_name" varchar(30) NOT NULL,
"email" varchar(75) NOT NULL,
"is_staff" boolean NOT NULL,
"is_active" boolean NOT NULL,
"date_joined" timestamp with time zone NOT NULL
)
;
EDIT: A screenshot from PHPPgAdmin, showing id as primary key
I think this is a bug with phpPgAdmin.
I experienced a similar problem and went directly into psql (using the command ./manage.py dbshell).
I tried deleting the row in question, and received a more helpful error message than the one from phpPgAdmin. (In my case, that the row was being referenced by another table.)
I deleted the row referenced by the other table, and was then able to delete the row in question.