Install DB schema files using cmake

fixes #6881
This commit is contained in:
Gunnar Beutner 2014-08-17 13:20:39 +02:00
parent 0ec5efafb5
commit 3da5568eb3
6 changed files with 42 additions and 31 deletions

View File

@ -38,4 +38,16 @@ if(MYSQL_FOUND)
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
)
install(
DIRECTORY schema
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-mysql
FILES_MATCHING PATTERN "*.sql"
)
install(
DIRECTORY schema/upgrade
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-mysql/schema
FILES_MATCHING PATTERN "*.sql"
)
endif()

View File

@ -40,4 +40,16 @@ if(PostgreSQL_FOUND)
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
)
install(
DIRECTORY schema
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-pgsql
FILES_MATCHING PATTERN "*.sql"
)
install(
DIRECTORY schema/upgrade
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2-ido-pgsql/schema
FILES_MATCHING PATTERN "*.sql"
)
endif()

View File

@ -1,4 +1,4 @@
components/db_ido_mysql/schema/*.sql usr/share/icinga2-ido-mysql/schema
components/db_ido_mysql/schema/upgrade/*.sql usr/share/icinga2-ido-mysql/schema/upgrade
usr/share/icinga2-ido-mysql/schema/*.sql
usr/share/icinga2-ido-mysql/schema/upgrade/*.sql
debian/ido-mysql.conf-sample usr/share/icinga2/tmpl
usr/lib/*/icinga2/libdb_ido_mysql*

View File

@ -1,4 +1,4 @@
components/db_ido_pgsql/schema/*.sql usr/share/icinga2-ido-pgsql/schema
components/db_ido_pgsql/schema/upgrade/*.sql usr/share/icinga2-ido-pgsql/schema/upgrade
usr/share/icinga2-ido-pgsql/schema/*.sql
usr/share/icinga2-ido-pgsql/schema/upgrade/*.sql
debian/ido-pgsql.conf-sample usr/share/icinga2/tmpl
usr/lib/*/icinga2/libdb_ido_pgsql*

View File

@ -484,24 +484,17 @@ setting up a MySQL database for Icinga 2:
After creating the database you can import the Icinga 2 IDO schema using the
following command:
# mysql -u root -p icinga < /usr/share/doc/icinga2-ido-mysql-*/schema/mysql.sql
The schema file location differs by the distribution used:
Distribution | Schema Files
--------------|---------------------
RHEL | `/usr/share/doc/icinga2-ido-mysql-*/schema` (* means package version).
SUSE | `/usr/share/doc/packages/icinga2-ido-mysql/schema`
Debian/Ubuntu | `/usr/share/icinga2-ido-mysql/schema`
# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
#### <a id="upgrading-mysql-db"></a> Upgrading the MySQL database
Check the `schema/upgrade` directory for an incremental schema upgrade file.
If there isn't an upgrade file available there's nothing to do.
Check the `/usr/share/icinga2-ido-mysql/schema/upgrade` directory for an
incremental schema upgrade file. If there isn't an upgrade file available
there's nothing to do.
Apply all database schema upgrade files incrementially.
# mysql -u root -p icinga < /usr/share/doc/icinga2-ido-mysql-*/schema/upgrade/<version>.sql
# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/upgrade/<version>.sql
The Icinga 2 DB IDO module will check for the required database schema version on startup
and generate an error message if not satisfied.
@ -565,26 +558,18 @@ After creating the database and permissions you can import the Icinga 2 IDO sche
using the following command:
# export PGPASSWORD=icinga
# psql -U icinga -d icinga < /usr/share/doc/icinga2-ido-pgsql-*/schema/pgsql.sql
The schema file location differs by the distribution used:
Distribution | Schema Files
--------------|---------------------
RHEL | `/usr/share/doc/icinga2-ido-pgsql-*/schema` (* means package version).
SUSE | `/usr/share/doc/packages/icinga2-ido-pgsql/schema`
Debian/Ubuntu | `/usr/share/icinga2-ido-pgsql/schema`
# psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql
#### <a id="upgrading-postgresql-db"></a> Upgrading the PostgreSQL database
Check the `schema/upgrade` directory for an incremental schema upgrade file.
If there isn't an upgrade file available there's nothing to do.
Check the `/usr/share/icinga2-ido-pgsql/schema/upgrade` directory for an
incremental schema upgrade file. If there isn't an upgrade file available
there's nothing to do.
Apply all database schema upgrade files incrementially.
# export PGPASSWORD=icinga
# psql -U icinga -d icinga < /usr/share/doc/icinga2-ido-pgsql-*/schema/upgrade/<version>.sql
# psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/upgrade/<version>.sql
The Icinga 2 DB IDO module will check for the required database schema version on startup
and generate an error message if not satisfied.

View File

@ -516,13 +516,15 @@ exit 0
%files ido-mysql
%defattr(-,root,root,-)
%doc components/db_ido_mysql/schema COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
%doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
%{_libdir}/%{name}/libdb_ido_mysql*
%{_datadir}/icinga2-ido-mysql
%files ido-pgsql
%defattr(-,root,root,-)
%doc components/db_ido_pgsql/schema COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
%doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
%{_libdir}/%{name}/libdb_ido_pgsql*
%{_datadir}/icinga2-ido-pgsql
%files classicui-config
%defattr(-,root,root,-)