Change of database schema from artifacts_publications to entities_publications

The following creates the entities_publications table and copies from the old artifacts_publications table.

USE cdli_db;

CREATE TABLE entities_publications LIKE artifacts_publications;

ALTER TABLE entities_publications
    RENAME COLUMN artifact_id to entity_id;

INSERT INTO entities_publications
    SELECT * FROM artifacts_publications;

ALTER TABLE entities_publications
    ADD COLUMN table_name varchar(255) NOT NULL;

ALTER TABLE `entities_publications` CHANGE `table_name` `table_name` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'artifacts';

UPDATE entities_publications
    SET table_name = 'artifacts';

Features to test:


Documentation

Documentation for Users

The migration from artifacts_publications to entities_publications does not really affect how users view publication data and their corresponding artifacts.

By going to the single publication view, such as http://localhost:2354/publications/1, one can find at the bottom all linked artifacts to this publication. In the future one could also see other types of entities as well.

By going to the single artifact view, such as http://localhost:2354/artifacts/1, one can expand the "Related Publications" tab and then find all linked publications to this artifact. In the future, for in the other entities' single view, one could also see related publications as well.

Documentation for Admin

As admin user, one could do the following.

(1) Add links between any publication and artifact

Go to Admin Dashboard -> Entities-Publications -> Add New. It would redirect to a form to fill in the artifact (or other type of entity) information and publication information. The link could then be generated from there.

(2) Add linked artifacts to a selected publication

By going to http://localhost:2354/publications/1, one can find "Link Artifacts" Button at the bottom. Clicking on the link artifacts would redirect to the add new link form with the publication information already filled.

In the future one would be able to add other linked entities.

(3) Add linked publications to a selected artifact.

By going to http://localhost:2354/artifacts/1, one can expand the "Related Publications" tab and see the "Link Publications" button. Clicking on it would redirect to the add new link form with the artifact information already filled.

In the future one would be able to add linked publications from other types of entities.

Documentation for Developers

The main idea is to add an entities_publications table in the cdli_db database as a join table between publications and various different types of entities (artifacts, dynasties, etc.). The entity_id and the publication_id are foreign keys, and there is a column called table_name which denotes to which table should one be finding the corresponding entity.

The code has been refactored: all uses of artifacts_publications has been changed to use entities_publications with a join condition that table_name = 'artifacts'. Also, unused features from the old ArtifactsPublications have been deleted.

Edited by Liangyuan (Circle) Chen

Merge request reports

Loading