Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Feature/prisma import update #126

Merged
merged 5 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 15 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"version": "5.2.0",
"description": "Dashboard backend",
"main": "dist/src/index.js",
"repository": "https://github.com/atherdon/dash-back",
"repository": {
"type": "git",
"url": "git+https://github.com/atherdon/dash-back.git"
},
"author": "kolserdav <serega12101983@gmail.com>",
"license": "MIT",
"private": false,
Expand All @@ -16,7 +19,7 @@
},
"scripts": {
"ts": "prisma generate && tsc -p . -w",
"ts:clean": "tsc --build --clean",
"ts:clean": "tsc --build --clean",
"build": "prisma generate && tsc -p . && yarn migrate",
"dev": "NODE_ENV=development nodemon ${npm_package_main}",
"start": "NODE_ENV=development node ${npm_package_main}",
Expand Down Expand Up @@ -68,7 +71,15 @@
"eslint-plugin-prettier": "3.3.1",
"gulp": "4.0.2",
"prettier": "2.2.1",
"prisma": "2.19.0",
"prisma": "^2.19.0",
"typescript": "4.2.3"
}
},
"bugs": {
"url": "https://github.com/atherdon/dash-back/issues"
},
"homepage": "https://github.com/atherdon/dash-back#readme",
"directories": {
"doc": "docs"
},
"keywords": []
}
7 changes: 4 additions & 3 deletions src/prisma/fill/fillExpandable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PrismaClient, Expandable } from '@prisma/client';
import { expandable2 } from '../../../data/expandable2.js';
import { expandable3 } from '../../../data/expandable3.js';
import { expandable2 } from '../../../data/expandable/expandable2.js';
import { expandable3 } from '../../../data/expandable/expandable3.js';
import * as lib from '../../lib';
const prisma = new PrismaClient();

Expand All @@ -18,7 +18,8 @@ export default async function fillExpandables(): Promise<void> {
id: undefined,
key: expandable.key,
name: expandable.name,
address: expandable.address,
address: undefined,
Copy link
Owner

Choose a reason for hiding this comment

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

can we completely remove this address field, please?

parentCategory: expandable.parentCategory,
articles: expandable.articles.join(','),
created: new Date(),
updated: new Date(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Warnings:

- You are about to drop the column `address` on the `Expandable` table. All the data in the column will be lost.
- Added the required column `parentCategory` to the `Expandable` table without a default value. This is not possible if the table is not empty.

*/
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Expandable" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"key" INTEGER NOT NULL,
"name" TEXT NOT NULL,
"parentCategory" TEXT NOT NULL,
"articles" TEXT NOT NULL,
"created" DATETIME DEFAULT CURRENT_TIMESTAMP,
"updated" DATETIME DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO "new_Expandable" ("id", "key", "name", "articles", "created", "updated") SELECT "id", "key", "name", "articles", "created", "updated" FROM "Expandable";
DROP TABLE "Expandable";
ALTER TABLE "new_Expandable" RENAME TO "Expandable";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;
16 changes: 8 additions & 8 deletions src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ model Article {
id Int @id @default(autoincrement())
url String
ready Boolean? @default(false)
type String // TODO change to enum when will use Mysql or Postgres
type String // TODO change to enum when will use Mysql or Postgres
isPublished Boolean? @default(false)
added DateTime
edited DateTime?
Expand All @@ -58,13 +58,13 @@ model Editor {
}

model Expandable {
id Int @id @default(autoincrement())
key Int
name String
address String
articles String
created DateTime? @default(now())
updated DateTime? @default(now())
id Int @id @default(autoincrement())
key Int
name String
parentCategory String
articles String
created DateTime? @default(now())
updated DateTime? @default(now())
}

model Filter {
Expand Down