Cara Memperbaiki Sequence Voucha4

Definisi Problem

Sequence adalah objek pada database yang digunakan untuk menentukan nilai dari field autoincrement (serial). Jika sequence rusak atau invalid, maka akan terjadi bentrok pada saat memasukkan data baru ke database. Jika sequence Voucha4 rusak, maka Anda tidak dapat menambah data pembelian, transaksi yang statusnya diproses tidak berubah statusnya padahal sudah selesai.

Akar Masalah

Kerusakan pada sequence disebabkan oleh tindakan melakukan instalasi ke database Voucha4 yang sudah ada data sebelumnya. Instalasinya memang gagal, namun beberapa objek pada database juga mengalami kerusakan.

Solusi

Untuk memperbaiki sequence yang rusak, silakan jalankan script SQL berikut di pgAdmin3 atau di command line psql.

SELECT SETVAL('public.belivocher_belivoucherid_seq', COALESCE(MAX(belivoucherid), 1) ) FROM public.belivoucher;
SELECT SETVAL('public.blacklist_messengerid_seq', COALESCE(MAX(sendertype), 1) ) FROM public.blacklist;
SELECT SETVAL('public.catalog_catalogid_seq', COALESCE(MAX(catalogid), 1) ) FROM public.catalog;
SELECT SETVAL('public.cluster_clusterid_seq', COALESCE(MAX(clusterid), 1) ) FROM public.cluster;
SELECT SETVAL('public.clusterproductblock_clusterproductblockid_seq', COALESCE(MAX(clusterproductblockid), 1) ) FROM public.clusterproductblock;
SELECT SETVAL('public.command_commandid_seq', COALESCE(MAX(commandid), 1) ) FROM public.command;
SELECT SETVAL('public.commandpardesc_commandpardescid_seq', COALESCE(MAX(commandpardescid), 1) ) FROM public.commandpardesc;
SELECT SETVAL('public.commandprefix_commandprefixid_seq', COALESCE(MAX(commandprefixid), 1) ) FROM public.commandprefix;
SELECT SETVAL('public.customer_customerid_seq', COALESCE(MAX(customerid), 1) ) FROM public.customer;
SELECT SETVAL('public.customergroup_customergroupid_seq', COALESCE(MAX(customergroupid), 1) ) FROM public.customergroup;
SELECT SETVAL('public.customergroupprice_customergrouppriceid_seq', COALESCE(MAX(customergrouppriceid), 1) ) FROM public.customergroupprice;
SELECT SETVAL('public.customertransaction_customertransactionid_seq', COALESCE(MAX(customertransactionid), 1) ) FROM public.customertransaction;
SELECT SETVAL('public.data_dummydevice_data_dummydeviceid_seq', COALESCE(MAX(data_dummydeviceid), 1) ) FROM public.data_dummydevice;
SELECT SETVAL('public.depositbank_depositbankid_seq', COALESCE(MAX(depositbankid), 1) ) FROM public.depositbank;
SELECT SETVAL('public.depositkas_depositkasid_seq', COALESCE(MAX(depositkasid), 1) ) FROM public.depositkas;
SELECT SETVAL('public.depositpiutang_depositpiutangid_seq', COALESCE(MAX(depositpiutangid), 1) ) FROM public.depositpiutang;
SELECT SETVAL('public.device_deviceid_seq', COALESCE(MAX(deviceid), 1) ) FROM public.device;
SELECT SETVAL('public.devicebelisaldo_devicebelisaldoid_seq', COALESCE(MAX(devicebelisaldoid), 1) ) FROM public.devicebelisaldo;
SELECT SETVAL('public.devicebeliunit_devicebeliunitid_seq', COALESCE(MAX(devicebeliunitid), 1) ) FROM public.devicebeliunit;
SELECT SETVAL('public.devicecategory_devicecategoryid_seq', COALESCE(MAX(devicecategoryid), 1) ) FROM public.devicecategory;
SELECT SETVAL('public.deviceinventory_deviceinventoryid_seq', COALESCE(MAX(deviceinventoryid), 1) ) FROM public.deviceinventory;
SELECT SETVAL('public.devicemsg_devicemsgid_seq', COALESCE(MAX(devicemsgid), 1) ) FROM public.devicemsg;
SELECT SETVAL('public.devicetransaction_devicetransactionid_seq', COALESCE(MAX(devicetransactionid), 1) ) FROM public.devicetransaction;
SELECT SETVAL('public.devicetranssaldo_devicetranssaldoid_seq', COALESCE(MAX(devicetranssaldoid), 1) ) FROM public.devicetranssaldo;
SELECT SETVAL('public.devicetransunit_devicetransunitid_seq', COALESCE(MAX(devicetransunitid), 1) ) FROM public.devicetransunit;
SELECT SETVAL('public.h2hlog_h2hlogid_seq', COALESCE(MAX(h2hlogid), 1) ) FROM public.h2hlog;
SELECT SETVAL('public.histinbox_histinboxid_seq', COALESCE(MAX(histinboxid), 1) ) FROM public.histinbox;
SELECT SETVAL('public.histoutbox_histoutboxid_seq', COALESCE(MAX(histoutboxid), 1) ) FROM public.histoutbox;
SELECT SETVAL('public.hlrfilter_filterid_seq', COALESCE(MAX(filterid), 1) ) FROM public.hlrfilter;
SELECT SETVAL('public.hlrlocation_locationid_seq', COALESCE(MAX(locationid), 1) ) FROM public.hlrlocation;
SELECT SETVAL('public.hlrproduct_hlrproductid_seq', COALESCE(MAX(hlrproductid), 1) ) FROM public.hlrproduct;
SELECT SETVAL('public.hlrproductblock_hlrproductblockid_seq', COALESCE(MAX(hlrproductblockid), 1) ) FROM public.hlrproductblock;
SELECT SETVAL('public.hlrregion_regionid_seq', COALESCE(MAX(regionid), 1) ) FROM public.hlrregion;
SELECT SETVAL('public.hlrroute_routeid_seq', COALESCE(MAX(routeid), 1) ) FROM public.hlrroute;
SELECT SETVAL('public.inbox_inboxid_seq', COALESCE(MAX(inboxid), 1) ) FROM public.inbox;
SELECT SETVAL('public.infonews_infonewsid_seq', COALESCE(MAX(infonewsid), 1) ) FROM public.infonews;
SELECT SETVAL('public.inventory_inventoryid_seq', COALESCE(MAX(inventoryid), 1) ) FROM public.inventory;
SELECT SETVAL('public.kasir_kasirid_seq', COALESCE(MAX(kasirid), 1) ) FROM public.kasir;
SELECT SETVAL('public.menu_menuid_seq', COALESCE(MAX(menuid), 1) ) FROM public.menu;
SELECT SETVAL('public.menugroup_menugroupid_seq', COALESCE(MAX(menugroupid), 1) ) FROM public.menugroup;
SELECT SETVAL('public.menupage_menupageid_seq', COALESCE(MAX(menupageid), 1) ) FROM public.menupage;
SELECT SETVAL('public.notifications_notificationid_seq', COALESCE(MAX(notificationid), 1) ) FROM public.notifications;
SELECT SETVAL('public.options_optionid_seq', COALESCE(MAX(optionid), 1) ) FROM public.options;
SELECT SETVAL('public.outbox_outboxid_seq', COALESCE(MAX(outboxid), 1) ) FROM public.outbox;
SELECT SETVAL('public.pengelolapiutang_pengelolapiutangid_seq', COALESCE(MAX(pengelolapiutangid), 1) ) FROM public.pengelolapiutang;
SELECT SETVAL('public.permission_permissionid_seq', COALESCE(MAX(permissionid), 1) ) FROM public.permission;
SELECT SETVAL('public.ppobcatalog_ppobcatalogid_seq', COALESCE(MAX(ppobcatalogid), 1) ) FROM public.ppobcatalog;
SELECT SETVAL('public.ppobresolution_ppobresolutionid_seq', COALESCE(MAX(ppobresolutionid), 1) ) FROM public.ppobresolution;
SELECT SETVAL('public.ppobtopup_ppobtopupid_seq', COALESCE(MAX(ppobtopupid), 1) ) FROM public.ppobtopup;
SELECT SETVAL('public.ppobtopuplog_ppobtopuplogid_seq', COALESCE(MAX(ppobtopuplogid), 1) ) FROM public.ppobtopuplog;
SELECT SETVAL('public.ppobwork_ppobworkid_seq', COALESCE(MAX(ppobworkid), 1) ) FROM public.ppobwork;
SELECT SETVAL('public.prefixfilter_prefixfilterid_seq', COALESCE(MAX(prefixfilterid), 1) ) FROM public.prefixfilter;
SELECT SETVAL('public.rebateprofile_rebateprofileid_seq', COALESCE(MAX(rebateprofileid), 1) ) FROM public.rebateprofile;
SELECT SETVAL('public.rebatetransaction_rebatetransactionid_seq', COALESCE(MAX(rebatetransactionid), 1) ) FROM public.rebatetransaction;
SELECT SETVAL('public.rekeningbank_rekeningbankid_seq', COALESCE(MAX(rekeningbankid), 1) ) FROM public.rekeningbank;
SELECT SETVAL('public.resolution_resolutionid_seq', COALESCE(MAX(resolutionid), 1) ) FROM public.resolution;
SELECT SETVAL('public.role_roleid_seq', COALESCE(MAX(roleid), 1) ) FROM public.role;
SELECT SETVAL('public.rolepermission_rolepermissionid_seq', COALESCE(MAX(rolepermissionid), 1) ) FROM public.rolepermission;
SELECT SETVAL('public.sessions_sessid_seq', COALESCE(MAX(sessid), 1) ) FROM public.sessions;
SELECT SETVAL('public.sqlmetadata_sqlmetadataid_seq', COALESCE(MAX(sqlmetadataid), 1) ) FROM public.sqlmetadata;
SELECT SETVAL('public.sqlmetaupdate_sqlmetaupdateid_seq', COALESCE(MAX(sqlmetaupdateid), 1) ) FROM public.sqlmetaupdate;
SELECT SETVAL('public.statisticdetail_statisticdetailid_seq', COALESCE(MAX(statisticdetailid), 1) ) FROM public.statisticdetail;
SELECT SETVAL('public.supplier_supplierid_seq', COALESCE(MAX(supplierid), 1) ) FROM public.supplier;
SELECT SETVAL('public.template_templateid_seq', COALESCE(MAX(templateid), 1) ) FROM public.template;
SELECT SETVAL('public.templatevardesc_templatevardescid_seq', COALESCE(MAX(templatevardescid), 1) ) FROM public.templatevardesc;
SELECT SETVAL('public.ticket_ticketid_seq', COALESCE(MAX(ticketid), 1) ) FROM public.ticket;
SELECT SETVAL('public.ticketlog_ticketlogid_seq', COALESCE(MAX(ticketlogid), 1) ) FROM public.ticketlog;
SELECT SETVAL('public.ticketmessage_ticketmessageid_seq', COALESCE(MAX(ticketmessageid), 1) ) FROM public.ticketmessage;
SELECT SETVAL('public.topup_topupid_seq', COALESCE(MAX(topupid), 1) ) FROM public.topup;
SELECT SETVAL('public.topuplog_topuplogid_seq', COALESCE(MAX(topuplogid), 1) ) FROM public.topuplog;
SELECT SETVAL('public.topupresult_topupresultid_seq', COALESCE(MAX(topupresultid), 1) ) FROM public.topupresult;
SELECT SETVAL('public.user_userid_seq', COALESCE(MAX(userid), 1) ) FROM public."user";
SELECT SETVAL('public.userrole_userroleid_seq', COALESCE(MAX(userroleid), 1) ) FROM public.userrole;
SELECT SETVAL('public.voucher_voucherid_seq', COALESCE(MAX(voucherid), 1) ) FROM public.voucher;
SELECT SETVAL('public.vouchertransaction_vouchertransactionid_seq', COALESCE(MAX(vouchertransactionid), 1) ) FROM public.vouchertransaction;
SELECT SETVAL('public.workitem_workitemid_seq', COALESCE(MAX(workitemid), 1) ) FROM public.workitem;

Tanya Jawab

Jika ada petunjuk yang belum jelas, silakan ditanyakan melalui situs QA kami di https://ask.voucha.co.id

Butuh Bantuan

Jika Anda membutuhkan bantuan untuk memperbaiki sequence yang rusak, silakan buka tiket support di Client Area dan memesan layanan recovery database. https://sandiloka.com/members/

Leave a Reply