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:
-
http://localhost:2354/, Index page, Elastic Search: If you type in keywords to search there should be results correctly returned, with no exceptions -
http://localhost:2354/publications/<publication_id>, Publication single view page -
Should be able to view associated artifacts as before -
If admin, should redirect to the "link entity" page when clicking on "link artifacts"
-
-
http://localhost:2354/artifacts/<artifact_id>, Artifact single view page : Should be able to view related publications as before -
http://localhost:2354/admin/dashboard, Admin Dashboard: Should be able to see "Entity-Publication links" card and go into "index" or "add new" -
http://localhost:2354/admin/entities-publications, Entities Publications index page: -
Should be able to view all entity-publication links -
Also, clicking on "Edit" for each link should redirect to edit page
-
-
http://localhost:2354/admin/entities-publications/add : Should be able to link an entity with a publication -
http://localhost:2354/admin/entities-publications/add/entity/ -
Should be able to link an entity to publication with a specific pub id -
Should be able to view the "linked artifacts" list, and the edit/delete button on the right should redirect to the correct edit/delete of the entity-pub link
-
-
http://localhost:2354/admin/entities-publications/add/publication/ : Should be able to link a publication to an entity with a specific entity id -
Different entity types may have same entity id, should probably change the code to also include an entity type in the URL as well -
Should be able to view the "linked pubs" list, and the edit/delete button on the right should redirect to the correct edit/delete of the entity-pub link
-
-
Editing entities-publications links, http://localhost:2354/admin/entities-publications/edit/<entity_publication link id>, should work:
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.