A database row says the payment status is 1. What does that mean?

The answer is somewhere in the application source. You need the right enum, from the right version, and some confidence that nobody has changed the mapping since the row was written.

That is my first objection to putting enum numbers in databases: the real value is hidden. A person inspecting the data sees a number where the business sees a condition. Reports, integrations, and investigations all need an explanation that lives somewhere else.

My second objection is worse. Someone can change that explanation without realizing they have changed the meaning of existing data.

This is specifically a database persistence problem. Components passing values through the same shared object definition have a common interpretation of the enum, so the concern is diminished. Stored rows outlive the application version that wrote them. The next version can bring a different definition to the same historical data.

Independently deployed components can still have version mismatches, so a shared definition needs compatible versions and serialization rules. That is a separate compatibility concern. My objection here is to storing a number whose business meaning depends on an application declaration elsewhere. I still prefer an Enumeration class as an extension of an enum for application code.

A harmless edit changes the past

Consider an application that stores these enum values directly:

public enum PaymentStatus
{
    Pending,  // 0
    Settled,  // 1
    Failed    // 2
}

A developer adds an authorization step:

public enum PaymentStatus
{
    Pending,     // 0
    Authorized,  // 1
    Settled,     // 2
    Failed       // 3
}

C# assigns successive values when the declaration does not specify them. Inserting a member changes the numbers assigned to later members. The language reference documents that behavior.

An existing row containing 1 now reads as Authorized. A row containing 2 now reads as Settled. No database update was necessary. The application changed the interpretation of the stored values.

The result is corrupted meaning. A failed payment can appear settled, and the number still maps to a valid enum member. Compilation succeeds. A test that writes and reads data using only the new version can succeed too.

This can be exceptionally hard to diagnose. The database contains plausible numbers, the application displays plausible states, and the original meaning depends on knowing which mapping applied when each row was written.

If old and new application versions both write during a rollout, the same number can acquire different meanings in the same column. Repair then requires evidence beyond that column: deployment history, audit events, or another record of the business action. Simply changing the enum back cannot distinguish those cases.

Store the meaning explicitly

My preference is to store a meaningful string value. A row containing SETTLED gives the person reading it an explanation that 1 cannot. Inserting a new member into an application enum does not change what that stored string says.

For a small set of states, the database can constrain those values directly:

CREATE TABLE Payment (
    Id bigint NOT NULL PRIMARY KEY,
    StatusCode varchar(20) NOT NULL,
    CONSTRAINT CK_Payment_StatusCode CHECK (
        StatusCode IN ('PENDING', 'AUTHORIZED', 'SETTLED', 'FAILED')
    )
);

The application should map its domain values to these codes deliberately. Calling ToString() on an enum and treating the result as the storage contract would make a future member rename a data change.

Strings have their own risks. Misspellings, inconsistent casing, whitespace, and renamed values can create disagreement between writers and readers. Define a canonical format, validate at the boundary, and choose database comparison rules that match the intended contract. A constraint limits the allowed values; its exact comparison behavior depends on the database and collation.

Treat SETTLED as a stable code, separate from a display label such as “Payment received.” Changing the label should not rewrite history. Retiring a code should prevent new use without making historical rows impossible to interpret.

Explicit numeric enum assignments can prevent accidental renumbering too. They are a useful immediate safeguard in an existing system, but they leave the stored meaning hidden. That is why I prefer strings.

A lookup table is another option

A lookup table with a foreign key makes the allowed values explicit and keeps their definitions in the database:

CREATE TABLE PaymentStatus (
    Code varchar(20) NOT NULL PRIMARY KEY,
    Name varchar(40) NOT NULL UNIQUE
);

INSERT INTO PaymentStatus (Code, Name)
VALUES ('PENDING', 'Pending'), ('AUTHORIZED', 'Authorized'),
       ('SETTLED', 'Settled'), ('FAILED', 'Failed');

CREATE TABLE Payment (
    Id bigint NOT NULL PRIMARY KEY,
    StatusCode varchar(20) NOT NULL,
    CONSTRAINT FK_Payment_PaymentStatus FOREIGN KEY (StatusCode)
        REFERENCES PaymentStatus (Code)
);

These are alternative schemas. The lookup version can carry descriptions and lifecycle information alongside each code. A numeric key is also possible, with a join to expose its meaning; using a string key retains readability in the referencing row as well.

A foreign key prevents a reference to an undeclared value. It cannot prevent someone from redefining an existing value, and it does not automatically teach an older application how to handle a newly added state. Reference data and application behavior still need a coordinated change policy.

A database-native enum is a different mechanism again, with its own migration rules. The problem here is treating an application's incidental numeric assignments as a durable data contract.

Fix the contract before changing the representation

If a system already stores enum ordinals, start by documenting what each stored value means. Verify that mapping against the deployed versions and actual data. Then pin existing identifiers explicitly before adding new states.

Moving to string codes or a lookup table requires a migration based on that verified mapping. Turning 1 into SETTLED is safe only after establishing that 1 actually meant Settled for the affected rows. Suspected corruption needs investigation before a migration can preserve the intended meaning.

Finally, test a new application version against representative rows written by its predecessor. Include unknown values and overlapping-version behavior where deployments allow it.

The database should remain understandable after the developer who wrote the enum has moved on. A stable identifier and a discoverable meaning are a useful place to start. The next article brings those decisions into the application through an enumeration class.