Camunda spring boot starter : create database in schema not working - business-process-management

I have used the camunda spring boot startup project (1.3.0) to spin up my camunda engine with the rest api.
In my application.yml I am trying to get camunda to create the database objects for me in a certain schema.
The settings below create the db objects...
camunda.bpm:
database:
schema-update: create-drop
type: postgres
table-prefix: my_schema.
spring.datasource:
url: "jdbc:postgresql://localhost:5432/mydb"
username: myuser
password: myuser
driverClassName: org.postgresql.Driver
The problem though is that the tables get created in the public schema. What I want to do is add a table-prefix equal to "my_schema."
Am I using this setting incorrectly or is there something I am missing?
thanks

Use
camunda:
bpm:
admin-user:
id: ${CM_ADMIN_USR:admin}
password: ${CM_ADMIN_PWD:admin}
database:
schema-update: false
schema-name: camunda
table-prefix: camunda.
Refer :
https://github.com/camunda/camunda-docs-manual/blob/master/content/user-guide/spring-boot-integration/configuration.md

Thorben is right: currently, camunda spring boot uses the normal database setup. So if (I actually never checked this) table_prefix is not supported, you cannot use it with spring boot.
I created an issue for removal: https://github.com/camunda/camunda-bpm-spring-boot-starter/issues/177

I resolved this issue by providing schema name as a suffix with the datasource URL
like :
url: "jdbc:postgresql://localhost:5432/mydb?currentSchema=my_schema"
Thus the tables should be created under the specified schema.

Related

Thingsboard with mysql

I wonder if Thingsboard can work with MySQL?
I tried to modify the PostgreSQL DAO Configuration in thingsboard.yml file, but it doesnt work. The installation fail.
spring:
data:
jpa:
repositories:
enabled: "true"
jpa:
hibernate:
ddl-auto: "validate"
database-platform: "${SPRING_JPA_DATABASE_PLATFORM:org.hibernate.dialect.MySQLDialect}"
datasource:
driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.mysql.jdbc.Driver}"
url: "${SPRING_DATASOURCE_URL:jdbc:mysql://localhost/thingsboard}"
username: "${SPRING_DATASOURCE_USERNAME:root}"
password: "${SPRING_DATASOURCE_PASSWORD:pw}"
make changes in thingsboard.yml 'DAO Configuration' section (maybe you need to add mysql port also).
review schema.sql and system-data.sql scripts to support MySQL dialect.
this pull request : https://github.com/thingsboard/thingsboard/pull/904
can helps
${SPRING_DRIVER_CLASS_NAME:org.mysql.jdbc.Driver} mean answer = SPRING_DRIVER_CLASS_NAME!=null ? SPRING_DRIVER_CLASS_NAME : org.mysql.jdbc.Driver
MySQL is currently not supported. We use hierarchical queries (a feature of PostgreSQL) for some specific requests. Migration is possible but will require code changes.

Rails Postgresql replication via Octopus gem when in Development env

Apparently when using the Octopus gem to do Postgres replication everything should be plug and play. However I can't seem to find what I'm doing wrong.
This is my config/shards.yml
octopus:
environments:
- development
replicated: true
development:
slave1:
adapter: postgresql
host: localhost
database: slaveapp_development
username: pguser
password: pgpass
The AR model Provider(I create the exact same tables in each app via Rake tasks) I'd like to sync/replicate to my slave:
class Provider < ActiveRecord::Base
has_many :products
replicated_model()
end
I boot both apps via Rails server and enter Masterapp's console and from there:
> Provider.using(:slave1).create({provider_params...})
#=> works! I get a new record in slave1's DB.
> Provider.using(:master).create({provider_params...})
#=> works partly. Creates record only in master's DB.
The problem is that when calling Provider.using(:master)... I'm expecting:
1 - Create record at master's DB.
2 - Replicate same record at slave1's DB. <--- This is NOT happening.
That is not the purpose of the Octopus gem.
It redirects the database requests, depending on whether it is a read or write operation. That way you can use your Rails models without thinking about the current database connection and if it fits the intended operation.
It does not copy the data to the slaves.
To perform the actual replication, i.e. the data transfer from the master to the slaves, you have to set it up yourself.
There are several options with PostgreSQL. If you are using a newer version (9.1+) you can use the integrated streaming replication in "hot standby" mode. There are tutorials on how to set it up, e.g.
http://www.rassoc.com/gregr/weblog/2013/02/16/zero-to-postgresql-streaming-replication-in-10-mins/
http://prongs.org/blog/postgresql-replication
If you are stuck with an older version of PostgreSQL have a look at the alternatives.
Try adding fully_replicated: false after replicated: true in your config.

Rails, Postgres, EC2/AWS: Database Config Does Not Specify Adapter Error

I'm trying to connect my Rails app to an EC2 instance that contains a PG database. I've already checked with Navicat that I can connect to the database given the EC2 details. The issue is that when run locally the Rails app can't be viewed; it throws the error "database configuration does not specify adapter". A similar issue is thrown when I try a database migration. I haven't even tried to push this up to my Rails EC2 since it isn't working locally.
My database.yml file looks like this:
production:
adapter: postgresql
encoding: unicode
database: postgres
host: ec2-54-197-115-117.compute-1.amazonaws.com
pool: 10
port: 5432 (have both included and removed this line)
username: a database username for security
password: the password associated with that user
My gem files include the gem pg.
For the database name I just wrote what it had in Navicat, but perhaps there's an official name associated with it I should be using; if so, how would I find it? The host I got from the EC2 details. And the username and password were the ones I set with the postgres database via unix.
Thanks in advance for any insight!
Edit:
Fixed!
Fixed! I had forgotten to create an actual DB after setting up the PG; I changed the name in my database.yml file to reflect the new db name. Also, I needed to set on my Rails app environment directly (I thought Apache did this automatically w/Passenger) with "export RAILS_ENV=production". I thought it was still broken when I restarted my server and nothing had changed, but I just had to restart the console. Hope this helps someone else out too!

Using an existing database of another Rails application in a new Rails application

I'm new to Rails. I had created a Rails application earlier and also collected a few data records in the development database. Suppose, I create a new Rails application and I prefer to use the existing development database of the 1st Rails application in my newly created Rails application, how do I do that?
Just change the file config/database.yml and set the database name.
your database.yml should look like this:
development:
host: localhost
adapter: mysql
database: your_database_name [just the name, not the path]
username: your_username
password: your_password
test:
...
production:
...
You need to change the database name in the database.yml file.
The seconnd problem you run into is migrations.
I would copy the migrations form your previous application over so that you maintain migration integrity with version numbers and rolling back if that is needed.
Also, if you are seeing development.locs - that locs refers to the table_name, which in restful context is usually also coincidentally the name of the controller.

Using embedded Derby with JRuby on Rails

Attempting to use JRuby 1.2.0 and Rails 2.3.2 with an embedded Derby database. I've copied derbytools.jar and derby.jar to $RUBY_HOME/lib, yet rake db:migrate still gives:
The driver encountered an error:
cannot load Java class org.apache.derby.jdbc.ClientDriver
Aaaand... I played a hunch and figured it out. So, I'll post this here in case somebody else runs into the same problem I did.
Almost all the documentation I found online has the following database.yml configuration for Derby:
development:
adapter: jdbc
driver: org.apache.derby.jdbc.ClientDriver
url: jdbc:derby:[db];create=true
username: xxx
password: xxx
This probably works fine for a client/server setup, but for an embedded Derby setup, you need this:
development:
adapter: jdbc
driver: org.apache.derby.jdbc.EmbeddedDriver
url: jdbc:derby:[db];create=true
username: xxx
password: xxx
Note the 'EmbeddedDriver', and not 'ClientDriver'.
Going to answer, because I hate seeing that red block in my profile.
There's also a subtle bug in ActiveRecord-JDBC when you use embedded derby -- if you don't give it a username and a password, nothing works. I've tracked down the cause of this bug, and am working on submitting a patch, but if you run into the same problem I did, let me know, and I'll post the code here.
Strange it worked fine for me , on my ubuntu 9.04 box :
i m using only the standard ubuntu packages and my DB configuration is :
development:
adapter: jdbc
driver: org.apache.derby.jdbc.EmbeddedDriver
url: jdbc:derby:[myapp];create=true
The ClientDriver is in derbyclient.jar
Further to Don's answer, I was getting this error when using the ClientDriver without a username/password: The driver encountered an error: java.sql.SQLNonTransientConnectionException: Password length (0) is outside the range of 1 to 255.
Setting username/password in database.yml fixed the problem!

Resources