我试图使用Postgres代替MySql来制作(1.2.0.Latest)Aerogear统一推送服务器(UPS)的最新发行版的dockerized版本。事实上,官方的UPS Docker发行版基于它。 使用Postgres连接器替换基础Docker文件中的连接器非常容易:
ENV POSTGRES_JDBC_VERSION 42.1.4
ENV db_module_dir=$JBOSS_HOME/modules/org/postgresql/main/
RUN mkdir -p ${db_module_dir}
RUN wget -O postgres-jdbc.jar http://central.maven.org/maven2/org/postgresql/postgresql/$POSTGRES_JDBC_VERSION/postgresql-$POSTGRES_JDBC_VERSION.jar
RUN mv postgres-jdbc.jar ${db_module_dir}
COPY configuration/xml/postgres-module.xml ${db_module_dir}/module.xml
我在旧版本中做了这个变化,一切正常。
现在,从头开始创建容器(通过Docker Compose)(没有预先存在的数据库)我从构建/迁移数据库模式/数据的Liquibase作业(jar)中收到以下错误:
Unexpected error running Liquibase: org.postgresql.util.PSQLException: ERROR: relation "PRIMARY" already exists
这是完整的日志:
myproject_ups_db | The files belonging to this database system will be owned by user "postgres".
myproject_ups_db | This user must also own the server process.
myproject_ups_db |
myproject_ups_db | The database cluster will be initialized with locale "en_US.utf8".
myproject_ups_db | The default database encoding has accordingly been set to "UTF8".
myproject_ups_db | The default text search configuration will be set to "english".
myproject_ups_db |
myproject_ups_db | Data page checksums are disabled.
myproject_ups_db |
myproject_ups_db | fixing permissions on existing directory /var/lib/postgresql/data ... ok
myproject_ups_db | creating subdirectories ... ok
myproject_ups_db | selecting default max_connections ... 100
myproject_ups_db | selecting default shared_buffers ... 128MB
myproject_ups_db | selecting dynamic shared memory implementation ... posix
myproject_ups_db | creating configuration files ... ok
myproject_ups_db | creating template1 database in /var/lib/postgresql/data/base/1 ... ok
myproject_ups_db | initializing pg_authid ... ok
myproject_ups_db | initializing dependencies ... ok
myproject_ups_db | creating system views ... ok
myproject_ups_db | loading system objects' descriptions ... ok
myproject_ups_db | creating collations ... ok
myproject_ups_db | creating conversions ... ok
myproject_ups_db | creating dictionaries ... ok
myproject_ups_db | setting privileges on built-in objects ... ok
myproject_ups_db | creating information schema ... ok
myproject_ups_db | loading PL/pgSQL server-side language ... ok
myproject_ups_db | vacuuming database template1 ... ok
myproject_ups_db | copying template1 to template0 ... ok
myproject_ups_db | copying template1 to postgres ... ok
myproject_ups_db | syncing data to disk ... ok
myproject_ups_db |
myproject_ups_db | Success. You can now start the database server using:
myproject_ups_db |
myproject_ups_db | postgres -D /var/lib/postgresql/data
myproject_ups_db | or
myproject_ups_db | pg_ctl -D /var/lib/postgresql/data -l logfile start
myproject_ups_db |
myproject_ups_db |
myproject_ups_db | WARNING: enabling "trust" authentication for local connections
myproject_ups_db | You can change this by editing pg_hba.conf or using the option -A, or
myproject_ups_db | --auth-local and --auth-host, the next time you run initdb.
myproject_ups_db | waiting for server to start....LOG: database system was shut down at 2017-09-23 16:00:34 UTC
myproject_ups_db | LOG: MultiXact member wraparound protections are now enabled
myproject_ups_db | LOG: database system is ready to accept connections
myproject_ups_db | LOG: autovacuum launcher started
myproject_ups_db | done
myproject_ups_db | server started
myproject_ups_db | CREATE DATABASE
myproject_ups_db |
myproject_ups_db | CREATE ROLE
myproject_ups_db |
myproject_ups_db |
myproject_ups_db | /docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/
myproject_ups_db |
myproject_ups_db | LOG: received fast shutdown request
myproject_ups_db | LOG: aborting any active transactions
myproject_ups_db | LOG: autovacuum launcher shutting down
myproject_ups_db | LOG: shutting down
myproject_ups_db | waiting for server to shut down....LOG: database system is shut down
myproject_ups_db | done
myproject_ups_db | server stopped
myproject_ups_db |
myproject_ups_db | PostgreSQL init process complete; ready for start up.
myproject_ups_db |
myproject_ups_db | LOG: database system was shut down at 2017-09-23 16:00:36 UTC
myproject_ups_db | LOG: MultiXact member wraparound protections are now enabled
myproject_ups_db | LOG: database system is ready to accept connections
myproject_ups_db | LOG: autovacuum launcher started
myproject_ups | Starting Liquibase migration
myproject_ups | Unexpected error running Liquibase: org.postgresql.util.PSQLException: ERROR: relation "PRIMARY" already exists
myproject_ups |
myproject_ups |
myproject_ups exited with code 255
有什么建议吗?
答案 0 :(得分:0)
最后,我找到了解决方案。我想在下面分享它。
问题来自Liquibase工作(jar)中包含的最新文件:
liquibase/1.2.0/2017-09-06-flat-model-entities.xml
只是评论指令:
<changeSet author="matzew (generated)" id="1504688114371-22">
<addPrimaryKey columnNames="push_message_variant_id" constraintName="PRIMARY" tableName="variant_error_status"/>
</changeSet>
解决了'错误:关系'PRIMARY“已存在”的问题。
之后,处理索引的“重复索引名称”还有两个问题:
在上面的同一个文件中,只需将它们重命名为
让一切正常,没有错误。
我猜这些错误与使用Postgres有关,也许Liquibase工作是为MySql设计的(并经过测试)。