Skip to content

Commit

Permalink
Merge pull request #30 from aura-nw/manga_col
Browse files Browse the repository at this point in the history
add chapter collection
  • Loading branch information
ThienLK1 authored Aug 8, 2024
2 parents 1a55e9b + f99209a commit fe92aa6
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
table:
name: chapter_collection
schema: public
object_relationships:
- name: chapter_collection
using:
foreign_key_constraint_on: launchpad_id
- name: collection_chapter
using:
foreign_key_constraint_on: chapter_id
1 change: 1 addition & 0 deletions hasura/metadata/databases/punkga-pg/tables/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- "!include public_banners.yaml"
- "!include public_campaign.yaml"
- "!include public_chains.yaml"
- "!include public_chapter_collection.yaml"
- "!include public_chapter_languages.yaml"
- "!include public_chapter_total_likes.yaml"
- "!include public_chapters.yaml"
Expand Down
20 changes: 20 additions & 0 deletions hasura/metadata/query_collections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1385,3 +1385,23 @@
id
}
}
- name: Admin - Delete Chapter Collection
query: |
mutation delete_chapter_collection_by_pk ($id: Int!) {
delete_chapter_collection_by_pk(id: $id) {
id
}
}
- name: Admin - Insert Chapter Collection
query: |
mutation MyMutation ($objects: [chapter_collection_insert_input!] = {}) {
insert_chapter_collection(objects: $objects, on_conflict: {constraint:chapter_collection_chapter_id_launchpad_id_key,update_columns:chapter_id}) {
affected_rows
returning {
chapter_id
created_at
id
launchpad_id
}
}
}
18 changes: 18 additions & 0 deletions hasura/metadata/rest_endpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@
- GET
name: Admin - Query campaign detail
url: admin/campaign/:id
- comment: Delete Chapter Collection
definition:
query:
collection_name: allowed-queries
query_name: Admin - Delete Chapter Collection
methods:
- DELETE
name: Admin - Delete Chapter Collection
url: admin/chapter-collection
- comment: "Insert Chapter Collection\nchapter_collection_insert_input:{\nchapter_id: Int!, \nlaunchpad_id: Int!\n}"
definition:
query:
collection_name: allowed-queries
query_name: Admin - Insert Chapter Collection
methods:
- POST
name: Admin - Insert Chapter Collection
url: admin/chapter-collection
- comment: ""
definition:
query:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE "public"."chapter_collection";
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE "public"."chapter_collection" ("id" serial NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "chapter_id" integer NOT NULL, "launchpad_id" integer NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("chapter_id") REFERENCES "public"."chapters"("id") ON UPDATE cascade ON DELETE cascade, FOREIGN KEY ("launchpad_id") REFERENCES "public"."launchpad"("id") ON UPDATE cascade ON DELETE cascade, UNIQUE ("chapter_id", "launchpad_id"));
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_chapter_collection_updated_at"
BEFORE UPDATE ON "public"."chapter_collection"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_chapter_collection_updated_at" ON "public"."chapter_collection"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

0 comments on commit fe92aa6

Please sign in to comment.