mirror of
https://github.com/Such-Software/medusa-plugin-blog.git
synced 2026-12-01 11:53:58 +01:00
make handles not nullable and unique
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Change Log
|
||||
|
||||
## 0.10.0
|
||||
## 0.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "medusa-plugin-blog",
|
||||
"version": ".1.0",
|
||||
"description": "Markdown-based blog for Medusa",
|
||||
"version": "0.0.1",
|
||||
"description": "Basic blog for Medusa",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pevey/medusa-plugin-blog"
|
||||
|
||||
@@ -5,7 +5,7 @@ export class Blog1684173263726 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE IF NOT EXISTS "blog_category" ("id" character varying NOT NULL,
|
||||
"handle" character varying,
|
||||
"handle" character varying UNIQUE NOT NULL,
|
||||
"title" character varying NOT NULL,
|
||||
"description" character varying,
|
||||
"keywords" varchar array,
|
||||
@@ -17,7 +17,7 @@ export class Blog1684173263726 implements MigrationInterface {
|
||||
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE IF NOT EXISTS "blog_post" ("id" character varying NOT NULL,
|
||||
"handle" character varying,
|
||||
"handle" character varying UNIQUE NOT NULL,
|
||||
"title" character varying NOT NULL,
|
||||
"author" character varying,
|
||||
"published" boolean NOT NULL DEFAULT false,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { BlogPost } from "./blog-post"
|
||||
export class BlogCategory extends BaseEntity {
|
||||
|
||||
@Index({ unique: true })
|
||||
@Column({ type: "varchar", nullable: true })
|
||||
@Column({ type: "varchar", nullable: false })
|
||||
handle: string | null
|
||||
|
||||
@Column({ type: "varchar", nullable: false })
|
||||
|
||||
@@ -8,7 +8,7 @@ import { BlogTag } from "./blog-tag"
|
||||
export class BlogPost extends BaseEntity {
|
||||
|
||||
@Index({ unique: true })
|
||||
@Column({ type: "varchar", nullable: true })
|
||||
@Column({ type: "varchar", nullable: false })
|
||||
handle: string | null
|
||||
|
||||
@Column({ type: "varchar", nullable: false })
|
||||
|
||||
@@ -46,7 +46,7 @@ export default class BlogService extends TransactionBaseService {
|
||||
|
||||
async addBlogCategory (category) {
|
||||
const { handle, title, description, keywords, metadata } = category
|
||||
if (!title) throw new Error("Adding a blog category requires a title")
|
||||
if (!handle || !title) throw new Error("Adding a blog category requires a unique handle and a title")
|
||||
/* @ts-ignore */
|
||||
const blogCategoryRepository = this.activeManager_.withRepository(this.blogCategoryRepository_)
|
||||
const createdCategory = blogCategoryRepository.create({
|
||||
@@ -62,7 +62,7 @@ export default class BlogService extends TransactionBaseService {
|
||||
|
||||
async updateBlogCategory (id, category) {
|
||||
const { handle, title, description, keywords, metadata } = category
|
||||
if (!id || !title) throw new Error("Updating a blog category requires an id and a title")
|
||||
if (!id || !title || !title) throw new Error("Updating a blog category requires an id, a unique handle, and a title")
|
||||
/* @ts-ignore */
|
||||
const blogCategoryRepository = this.activeManager_.withRepository(this.blogCategoryRepository_)
|
||||
const blogCategory = blogCategoryRepository.update(id, {
|
||||
@@ -205,7 +205,7 @@ export default class BlogService extends TransactionBaseService {
|
||||
|
||||
async addBlogPost(post) {
|
||||
const { handle, title, author, published, content, description, keywords, category_id, tag_ids, product_ids, collection_ids, metadata } = post
|
||||
if (!title) throw new Error("Adding a blog post requires a title")
|
||||
if (!handle || !title) throw new Error("Adding a blog post requires a unique handle and a title")
|
||||
let tags = []
|
||||
if (tag_ids) {
|
||||
/* @ts-ignore */
|
||||
@@ -261,7 +261,7 @@ export default class BlogService extends TransactionBaseService {
|
||||
|
||||
async updateBlogPost(id, post) {
|
||||
const { handle, title, author, published, content, description, keywords, category_id, tag_ids, product_ids, collection_ids, metadata } = post
|
||||
if (!id || !title) throw new Error("Updating a blog post requires an id and a title")
|
||||
if (!id || !handle || !title) throw new Error("Updating a blog post requires an id, a unique handle, and a title")
|
||||
let tags = []
|
||||
if (tag_ids) {
|
||||
/* @ts-ignore */
|
||||
|
||||
Reference in New Issue
Block a user