Commit Graph

3 Commits

Author SHA1 Message Date
Witold Bedyk 6409d06439 Set up DB schema in DevStack plugin using Alembic
SQL schema scripts are replaced with Alembic command line tool.
Notification plugins are enabled in notification engine configuration
file.

The change also fixes the `sub_alarm` table schema. The foreign key must
refer to the field with the same data type, charset and collation.
Otherwise the schema migration fails occasionally with Python 3 with the
IntegrityError[1]:

  oslo_db.exception.DBError: (pymysql.err.IntegrityError) (1215, 'Cannot add foreign key constraint')

[1] http://logs.openstack.org/61/622361/8/gate/monasca-tempest-python3-influxdb/26104a3/controller/logs/devstacklog.txt.gz#_2019-01-30_15_52_45_455

Change-Id: I95d7e91e62ff13e84f963fdbb3bca6b7dfd7c310
Story: 2001654
Task: 14421
2019-02-20 14:53:10 +01:00
Johannes Grassler 0250f81cdc Add monasca_db command line tool
This commit adds a schema management tool for the Monasca
configuration database. Apart from the usual OpenStack schema
management tool subcommands (stamp, upgrade, version) it has
two extra subcommands:

* fingerprint: for computing a SHA1 fingerprint of the
               currently currently active database schema.
* detect-revision: for identifiying the Alembic revision
                   (if any) corresponding to a database
                   schema that was created with one of the
                   legacy SQL scripts.

The data provided by the detect-revision subcommand can be
used for stamping the database with Alembic version metadata
when transitioning an existing Monasca configuration database
to Alembic based database migrations.

Story: 2001654
Task: 14341

Change-Id: Ibdd877a23ab5d6d1bbf8d83515c0197554098526
2018-08-01 11:10:14 +00:00
Johannes Grassler 39d5bbbb0a Alembic migrations for all SQL script revisions
This commit adds

* An alembic environment for running database migrations
* Alembic database migrations for all revisions
  of the legacy SQL script currently being used to set up the
  Monasca database.
* The get_all_metadata() function for exposing full data model
  metadata. This function is needed generating migrations from
  the current state of the model and should be kept up to date
  as the model is being extended.

Change-Id: I41b4577d8334791f712177348cadfe9b07b62ef1
Story: 2001654
Task: 14339
2018-06-22 08:16:35 +00:00