mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-hlr.git
synced 2025-10-23 08:22:12 +00:00
add database schema versioning to the HLR database
Make use of pragma user_version to store our database schema version. The present schema is now identitifed as 'version 0', which is also the default value for databases on which we never ran the statement 'pragma user_version' before. Only bootstrap the database if it hasn't been bootstrapped yet. Previously, bootstrap SQL statements ran every time osmo-hlr opened the database, and any errors were being ignored in SQL. Instead, we now first run a query which checks whether tables already exist, and only create them if necessary. This change will allow future schema updates to work properly. Prepare for future schema upgrades by adding a new command-line option which enables upgrades. This option defaults to 'false' in order to avoid accidental upgrades. Change-Id: I8aeaa9a404b622657cbc7138106f38aa6ad8d01b Related: OS#2838
This commit is contained in:
committed by
Neels Hofmeyr
parent
a820ea1f67
commit
8f3a7cce80
15
sql/hlr.sql
15
sql/hlr.sql
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE IF NOT EXISTS subscriber (
|
||||
CREATE TABLE subscriber (
|
||||
-- OsmoHLR's DB scheme is modelled roughly after TS 23.008 version 13.3.0
|
||||
id INTEGER PRIMARY KEY,
|
||||
-- Chapter 2.1.1.1
|
||||
@@ -39,24 +39,24 @@ CREATE TABLE IF NOT EXISTS subscriber (
|
||||
ms_purged_ps BOOLEAN NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS subscriber_apn (
|
||||
CREATE TABLE subscriber_apn (
|
||||
subscriber_id INTEGER, -- subscriber.id
|
||||
apn VARCHAR(256) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS subscriber_multi_msisdn (
|
||||
CREATE TABLE subscriber_multi_msisdn (
|
||||
-- Chapter 2.1.3
|
||||
subscriber_id INTEGER, -- subscriber.id
|
||||
msisdn VARCHAR(15) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS auc_2g (
|
||||
CREATE TABLE auc_2g (
|
||||
subscriber_id INTEGER PRIMARY KEY, -- subscriber.id
|
||||
algo_id_2g INTEGER NOT NULL, -- enum osmo_auth_algo value
|
||||
ki VARCHAR(32) NOT NULL -- hex string: subscriber's secret key (128bit)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS auc_3g (
|
||||
CREATE TABLE auc_3g (
|
||||
subscriber_id INTEGER PRIMARY KEY, -- subscriber.id
|
||||
algo_id_3g INTEGER NOT NULL, -- enum osmo_auth_algo value
|
||||
k VARCHAR(32) NOT NULL, -- hex string: subscriber's secret key (128bit)
|
||||
@@ -66,4 +66,7 @@ CREATE TABLE IF NOT EXISTS auc_3g (
|
||||
ind_bitlen INTEGER NOT NULL DEFAULT 5 -- nr of index bits at lower SQN end
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_subscr_imsi ON subscriber (imsi);
|
||||
CREATE UNIQUE INDEX idx_subscr_imsi ON subscriber (imsi);
|
||||
|
||||
-- Set HLR database schema version number
|
||||
PRAGMA user_version = 0;
|
||||
|
Reference in New Issue
Block a user