Skip to main content

Schema changes

This section describes the schema changes happening between different Data Orchestrator Versions.

They are divided between Data Orchestrator Keyspace (changes that affect the Data Orchestrator Keyspace), and Realm Keyspaces (changes that affect all realm keyspaces).

Every change is followed by the CQL statement that produces the change.

From v0.10 to v0.11​

Data Orchestrator Keyspace v0.11 Changes​

  • Remove astarte_schema table
DROP TABLE astarte_schema;
  • Remove replication_factor column from the realms table
ALTER TABLE realms
DROP replication_factor;

Realm Keyspaces v0.11 Changes​

  • Add grouped_devices table
CREATE TABLE <realm_name>.grouped_devices (
group_name varchar,
insertion_uuid timeuuid,
device_id uuid,
PRIMARY KEY ((group_name), insertion_uuid, device_id)
);
  • Add groups, exchanged_bytes_by_interface and exchanged_msgs_by_interface columns to the devices table
ALTER TABLE <realm_name>.devices
ADD (groups map<varchar, timeuuid>,
exchanged_bytes_by_interface map<frozen<tuple<ascii, int>>, bigint>,
exchanged_msgs_by_interface map<frozen<tuple<ascii, int>>, bigint>);
  • Add database_retention_ttl and database_retention_policy columns to the endpoints table
ALTER TABLE <realm_name>.endpoints
ADD (
database_retention_ttl int,
database_retention_policy int
);

From v0.11 to v1.0.0-beta.1​

Realm Keyspace v1.0.0-beta.1 Changes​

  • The connected field of the devices table is now saved with a TTL, so it automatically expires if it doesn't gets refreshed by the heartbeat sent by the broker. This behaviour was added to avoid stale connected devices if they disconnect while the broker is down.

  • Add metadata column to the devices table

ALTER TABLE devices
ADD (
metadata map<varchar, varchar>
);

From v1.0-beta.1 to v1.0.0​

Realm Keyspace v1.0.0 Changes​

  • Rename the metadata to attributes in the devices table

Warning: migrating data from the metadata column to the attributes one is possible but is out of scope of this guide since this change happened between development releases. The procedure below just creates the new column and then deletes the old one without migrating data. You're free to implement a migration procedure between the two steps.

ALTER TABLE devices
ADD (
attributes map<varchar, varchar>
);
ALTER TABLE devices
DROP metadata;