-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from GesangPJ/test
Tambah Fitur Jurnal, Fix Bug Tambah Produk
- Loading branch information
Showing
10 changed files
with
167 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
prisma/migrations/20240808100234_buat_jurnal/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- CreateTable | ||
CREATE TABLE "JurnalTransaksi" ( | ||
"id" SERIAL NOT NULL, | ||
"transaksiId" INTEGER NOT NULL, | ||
"kode" TEXT NOT NULL, | ||
"pemasukan" INTEGER NOT NULL DEFAULT 0, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "JurnalTransaksi_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "JurnalPembelian" ( | ||
"id" SERIAL NOT NULL, | ||
"pembelianId" INTEGER NOT NULL, | ||
"kode" TEXT NOT NULL, | ||
"pengeluaran" INTEGER NOT NULL DEFAULT 0, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "JurnalPembelian_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "JurnalTransaksi" ADD CONSTRAINT "JurnalTransaksi_transaksiId_fkey" FOREIGN KEY ("transaksiId") REFERENCES "Transaksi"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "JurnalPembelian" ADD CONSTRAINT "JurnalPembelian_pembelianId_fkey" FOREIGN KEY ("pembelianId") REFERENCES "Pembelian"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Reset Transaksi | ||
|
||
import { PrismaClient } from '@prisma/client' | ||
|
||
const prisma = new PrismaClient() | ||
|
||
async function main() { | ||
try { | ||
// Hapus semua data dari tabel transaksi detail dan transaksi | ||
await prisma.transaksiDetail.deleteMany({}) | ||
await prisma.transaksi.deleteMany({}) | ||
console.log('Berhasil menghapus semua data di tabel Transaksi Detail & Transaksi.') | ||
|
||
// Reset ID TransaksiDetail dan Transaksi dari 1 | ||
await prisma.$executeRaw`ALTER SEQUENCE "TransaksiDetail_id_seq" RESTART WITH 1` | ||
await prisma.$executeRaw`ALTER SEQUENCE "Transaksi_id_seq" RESTART WITH 1` | ||
console.log('Berhasil mereset ID di tabel Transaksi Detail & Transaksi.') | ||
|
||
} catch (error) { | ||
console.error('Error menghapus data dan reset ID Transaksi Detail & Transaksi :', error) | ||
} finally { | ||
await prisma.$disconnect() | ||
} | ||
} | ||
|
||
main() | ||
.catch((e) => { | ||
console.error(e) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters