Giter Club home page Giter Club logo

Comments (7)

ardan-bkennedy avatar ardan-bkennedy commented on September 14, 2024 2

I need more information. You will need to add a new version entry to the migration document. You can't edit a version that has been applied. Is this what you mean?

from service.

mrbardia72 avatar mrbardia72 commented on September 14, 2024 1

You said here
You will need to add a new version entry to the migration document.
For example, if I want to edit a field, how should I do this?
For example, I want to change the name of a field or its type
@ardan-bkennedy

from service.

mrbardia72 avatar mrbardia72 commented on September 14, 2024

Yes, that's what I mean
We have two cases:
1- Adding a field to the table
2- Changing the type of that field
If possible, write me an example here

from service.

himynamej avatar himynamej commented on September 14, 2024

Occasionally you will make a mistake when writing a migration. If you have already run the migration then you cannot just edit the migration and run the migration again.you must add new version of the migration or rollback the old migration.

from service.

mrbardia72 avatar mrbardia72 commented on September 14, 2024

How should I do what you said?
Do you have a test sample?

After that, this rollback method does not cause data loss

@himynamej

from service.

ardan-bkennedy avatar ardan-bkennedy commented on September 14, 2024

You would use an ALTER COLUMN command in a new version of the migration. Here is a good example

-- Version: 1.19
-- Description: Alter payments table.
ALTER TABLE payments ADD COLUMN gateway_status INT NULL;
ALTER TABLE payments ADD COLUMN gateway_description TEXT NULL;
ALTER TABLE payments ADD COLUMN failed BOOL NULL;
UPDATE payments SET failed = false WHERE status != 'failed';
UPDATE payments SET failed = true WHERE status = 'failed';
ALTER TABLE payments ALTER COLUMN failed SET NOT NULL;

from service.

mrbardia72 avatar mrbardia72 commented on September 14, 2024

tnx

from service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.