Comments (7)
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.
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.
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.
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.
How should I do what you said?
Do you have a test sample?
After that, this rollback method does not cause data loss
from service.
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.
tnx
from service.
Related Issues (20)
- pass in dbtest tokenv1 HOT 1
- user role question HOT 4
- More complicated role HOT 2
- Unit test HOT 5
- layer called userapp! HOT 4
- error when run multiple instances HOT 1
- Tests HOT 5
- Question: Respond before commit transaction HOT 3
- Add account verification link HOT 3
- Transaction error 500 when testing transaction with validation error 400 HOT 2
- Code generates HOT 1
- Question: API integration HOT 2
- It is suggested to improve the naming of returned errors from the database layer HOT 1
- Question about vproduct domain HOT 2
- Support nullable types in DB schema HOT 3
- Question about pointer semantic HOT 1
- Question about logger HOT 1
- Why NewWithTx returns an interface instead of concrete type? HOT 1
- Proposal for Front-End Architecture Using Templ and HTMX HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from service.