Skip to content

Comments

Implement shared ID for public links and shares#20

Merged
diocas merged 2 commits intomasterfrom
fix/shared-ids-sharing
Mar 7, 2025
Merged

Implement shared ID for public links and shares#20
diocas merged 2 commits intomasterfrom
fix/shared-ids-sharing

Conversation

@jessegeens
Copy link
Contributor

@jessegeens jessegeens commented Mar 5, 2025

Through this PR, a new table share_ids is added to the database, which contains the sequence of IDs that are shared between public links and shares:

+-------+-----------------+------+-----+---------+----------------+
| Field | Type            | Null | Key | Default | Extra          |
+-------+-----------------+------+-----+---------+----------------+
| id    | bigint unsigned | NO   | PRI | NULL    | auto_increment |
+-------+-----------------+------+-----+---------+----------------+

This is required to comply with Web's requirement of having unique IDs across the different share types.

The shares table (and similaryly the public_links table) remains unchanged, except for the facts that:

  • Id is now a Foreign Key to share_ids.id
  • Id is no longer the primary key. Instead the primary key is a composite key on (storage_id, inode, share_with)
+----------------------+------------------+------+-----+---------+-------+
| Field                | Type             | Null | Key | Default | Extra |
+----------------------+------------------+------+-----+---------+-------+
| id                   | bigint unsigned  | YES  | UNI | NULL    |       |
| created_at           | datetime(3)      | YES  |     | NULL    |       |
| updated_at           | datetime(3)      | YES  |     | NULL    |       |
| deleted_at           | datetime(3)      | YES  | MUL | NULL    |       |
| uid_owner            | varchar(64)      | YES  |     | NULL    |       |
| uid_initiator        | varchar(64)      | YES  |     | NULL    |       |
| item_type            | varchar(16)      | YES  |     | NULL    |       |
| initial_path         | longtext         | YES  |     | NULL    |       |
| inode                | varchar(32)      | NO   | PRI | NULL    |       |
| instance             | varchar(32)      | NO   | PRI | NULL    |       |
| permissions          | tinyint unsigned | YES  |     | NULL    |       |
| orphan               | tinyint(1)       | YES  |     | NULL    |       |
| expiration           | datetime(3)      | YES  |     | NULL    |       |
| share_with           | varchar(255)     | NO   | PRI | NULL    |       |
| shared_with_is_group | tinyint(1)       | YES  |     | NULL    |       |
| description          | varchar(1024)    | YES  |     | NULL    |       |
+----------------------+------------------+------+-----+---------+-------+
| shares | CREATE TABLE `shares` (
  `id` bigint unsigned DEFAULT NULL,
  `created_at` datetime(3) DEFAULT NULL,
...
  `shared_with_is_group` tinyint(1) DEFAULT NULL,
  `description` varchar(1024) DEFAULT NULL,
  PRIMARY KEY (`inode`,`instance`,`share_with`),
  UNIQUE KEY `idx_shares_id` (`id`),
  KEY `idx_shares_deleted_at` (`deleted_at`),
  KEY `i_share_with` (`share_with`),
  CONSTRAINT `fk_shares_share_id` FOREIGN KEY (`id`) REFERENCES `share_ids` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |

@jessegeens jessegeens marked this pull request as ready for review March 5, 2025 12:46
@jessegeens jessegeens force-pushed the fix/shared-ids-sharing branch 19 times, most recently from f3ef4ac to 9415aef Compare March 6, 2025 13:17
@jessegeens jessegeens force-pushed the fix/shared-ids-sharing branch from 9415aef to e9f14e0 Compare March 6, 2025 13:26
Copy link
Member

@glpatcern glpatcern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good for me, there's just a trivial change

diocas added a commit to cernbox/revaold that referenced this pull request Mar 6, 2025
@diocas diocas merged commit e96cc8f into master Mar 7, 2025
1 check passed
@jessegeens jessegeens deleted the fix/shared-ids-sharing branch March 7, 2025 08:25
diocas added a commit to cernbox/revaold that referenced this pull request Mar 7, 2025
diocas added a commit to cernbox/revaold that referenced this pull request Mar 10, 2025
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.

3 participants