Skip to content

refactor: Update for alpenhorn data index changes - #33

Merged
ketiltrout merged 1 commit into
mainfrom
db_update
Apr 2, 2026
Merged

refactor: Update for alpenhorn data index changes#33
ketiltrout merged 1 commit into
mainfrom
db_update

Conversation

@ketiltrout

Copy link
Copy Markdown
Member

See: radiocosmology/alpenhorn#365 and radiocosmology/alpenhorn#369

  • Adds the new StorageHost table.
  • Updates StorageNode:
    • remove address and username (moved to StorageHost)
    • change host to a foreign key to the StorageHost table.
    • replace storage_type enum with archive boolean.
    • delete obsolete fields suspect and min_delete_age_days
  • Update util.update_storage:
    • handle StorageHost creation
    • Delete now-unused cedar_offload node.
    • Update node names for fir

@ketiltrout

Copy link
Copy Markdown
Member Author

I have added the new columns to the production database (without removing the old columns):

-- Add archive column to the storagenode table
START TRANSACTION;
ALTER TABLE storagenode ADD COLUMN IF NOT EXISTS archive TINYINT(1) NOT NULL DEFAULT 0 AFTER suspect;
UPDATE storagenode set archive=1 WHERE storage_type='A';
COMMIT;

-- Create and populate the storagehost table
START TRANSACTION;
CREATE TABLE storagehost (id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(64) NOT NULL UNIQUE, username VARCHAR(64) DEFAULT NULL, address varchar(64) DEFAULT NULL, notes LONGTEXT);
INSERT INTO storagehost VALUES(1, "gong", "chimeadmin", "hac1-nren.chimenet.ca", "At the CHIME telescope.  Data is on gong, but the alpenhorn daemon runs on wind.");
INSERT INTO storagehost VALUES(2, "fir", "chimedat", "robot.fir.alliancecan.ca", "WestGrid compute cluster.");
INSERT INTO storagehost VALUES(3, "scinet", "chimedat", "robot3.scinet.utoronto.ca", "SciNet compute cluster.  Access via trillium.");
COMMIT;

-- Add a host_id foreign key to the storagenode table
START TRANSACTION;
ALTER TABLE storagenode ADD COLUMN IF NOT EXISTS host_id INT DEFAULT NULL AFTER host;
ALTER TABLE storagenode ADD CONSTRAINT storagenode_ibfk_2 FOREIGN KEY (host_id) REFERENCES storagehost (id);
UPDATE storagenode SET host_id=1 WHERE host="wind" AND active=1;
UPDATE storagenode SET host_id=2 WHERE host="cedar5" AND active=1;
UPDATE storagenode SET host_id=3 WHERE host="scinet" AND active=1;
COMMIT;

See: radiocosmology/alpenhorn#365 and radiocosmology/alpenhorn#369

* Adds the new `StorageHost` table.
* Updates `StorageNode`:
  * remove `address` and `username` (moved to `StorageHost`)
  * change `host` to a foreign key to the `StorageHost` table.
  * replace `storage_type` enum with `archive` boolean.
  * delete obsolete fields `suspect` and `min_delete_age_days`
* Update `util.update_storage`:
  * handle `StorageHost` creation
  * Delete now-unused `cedar_offload` node.
  * Update node names for `fir`
@ketiltrout
ketiltrout merged commit 3d97ff5 into main Apr 2, 2026
3 checks passed
@ketiltrout
ketiltrout deleted the db_update branch April 2, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants