pymysql.err.OperationalError: (4091, "Unknown SEQUENCE: 'selling_step_id_seq'") - Autoincrement Doctype name error

I am getting this error on saving a record in selling step doctype in erpnext. My doctype has naming series set as Autoincrement. pymysql.err.OperationalError: (4091, "Unknown SEQUENCE: 'selling_step

 · 1 min read

The error you're encountering, pymysql.err.OperationalError: (4091, "Unknown SEQUENCE: 'selling_step_id_seq'"), typically indicates that the sequence selling_step_id_seq does not exist in your database. This sequence is likely used to generate unique IDs for records in the selling_step doctype.

Here are a few steps you can take to resolve this issue:

1. Verify Sequence Creation

Check if the sequence selling_step_id_seq exists in your database. You can do this by running a query directly in your database management tool.

For example, if you are using PostgreSQL, you can run:

sql
Copy code
SELECT * FROM pg_sequences WHERE sequencename = 'selling_step_id_seq';

2. Create the Sequence Manually

If the sequence does not exist, you can create it manually. Here’s how you can create it in PostgreSQL:

sql
Copy code
CREATE SEQUENCE selling_step_id_seq;

For MySQL, you might need to check if the database is set to use sequences or auto-increment. Usually, MySQL does not use sequences in the same way as PostgreSQL, so this error might indicate a deeper configuration issue or a mismatch in the database type expected.

3. Check Your DocType Configuration

Ensure that the selling_step doctype is correctly configured to use the sequence. This might involve checking the schema definitions and any custom scripts or settings applied to this doctype.

4. Database Schema Migration

If the sequence is supposed to be created by a migration script or during the setup of the selling_step doctype, try running the migrations again to ensure all necessary database objects are created.

In your ERPNext installation directory, you can run:

sh
Copy code
bench migrate

This command applies any pending schema changes and should create any missing sequences.


Book a free 30min tailored consultation

Free first 30min of enterprise consultation to manage your business better using digital processes.


No comments yet.

Add a comment
Ctrl+Enter to add comment