Comments (1)
In the event of a schema conflict like in scenario 1 above that prevents using a rebase workflow, you can still use a merge workflow to update the branch. (Using rebase to try and squash the commits on the dev branch into a single commit that can then be rebased onto the tip of main, will still currently hit a schema conflict.)
1 – Bring the schema into sync with the upstream branch
We can use the dolt_patch()
table function to easily find the SQL statements needed to migrate the schema to match main
:
-- find the schema differences using dolt_patch()
select statement_order, statement from dolt_patch('branch1', 'main') where diff_type="schema";
+-----------------+-------------------------------+
| statement_order | statement |
+-----------------+-------------------------------+
| 1 | ALTER TABLE `t` DROP `c1`; |
| 2 | ALTER TABLE `t` ADD `c1` int; |
+-----------------+-------------------------------+
-- apply the schema changes
ALTER TABLE `t` DROP `c1`;
ALTER TABLE `t` ADD `c1` int;
-- create a Dolt commit
call dolt_commit('-am', 'updating schemas to match main');
2 – Merge the latest changes from the upstream branch into the dev branch.
-- before merging main to branch1, we can look at the current log for branch1 to see the reachable commits
select * from dolt_log;
+----------------------------------+-----------+-------------------------+---------------------+--------------------------------+
| commit_hash | committer | email | date | message |
+----------------------------------+-----------+-------------------------+---------------------+--------------------------------+
| 314crgv3oj20o2blsjcin3g50nld258j | root | root@localhost | 2024-05-07 23:35:43 | updating schemas to match main |
| jmstip9r3d992h80ik5v95a76d4l7rnc | root | root@localhost | 2024-05-07 23:34:48 | inserting row 100 on branch1 |
| 38lpgag8jkbjo7l5gsmnfks4vgjqo6h3 | root | root@localhost | 2024-05-07 23:34:48 | adding row 1 on main |
| df42kstlos2i84c7vujnv6kofrudn332 | root | root@localhost | 2024-05-07 23:34:48 | adding table t on main |
| d0ltbo8su41muhftfg3gm6jr6re19jpt | jfulghum | jason.fulghum@gmail.com | 2024-05-07 23:29:01 | Initіаlіze datа rеpоsitory |
+----------------------------------+-----------+-------------------------+---------------------+--------------------------------+
-- merge the main branch into branch1
call dolt_merge('main');
+----------------------------------+--------------+-----------+------------------+
| hash | fast_forward | conflicts | message |
+----------------------------------+--------------+-----------+------------------+
| bjjli2hp9jti0vc9djdkss7gtceenuof | 0 | 0 | merge successful |
+----------------------------------+--------------+-----------+------------------+
-- now examine the commit log for branch1 and we can see new commits from main are now reachable
-- on branch1 (e.g. "adding row 2 on main")
rebaseSchemaConflictResolution/branch1> select * from dolt_log;
+----------------------------------+-----------+-------------------------+---------------------+------------------------------------+
| commit_hash | committer | email | date | message |
+----------------------------------+-----------+-------------------------+---------------------+------------------------------------+
| bjjli2hp9jti0vc9djdkss7gtceenuof | root | root@localhost | 2024-05-07 23:53:07 | Merge branch 'main' into branch1 |
| 314crgv3oj20o2blsjcin3g50nld258j | root | root@localhost | 2024-05-07 23:35:43 | updating schemas to match main |
| jp0kv3re8ltafhef1k0a4g7p66t4gu53 | root | root@localhost | 2024-05-07 23:34:48 | dropping and readding t.c1 on main |
| jmstip9r3d992h80ik5v95a76d4l7rnc | root | root@localhost | 2024-05-07 23:34:48 | inserting row 100 on branch1 |
| bohjglronlvql4ltdkekloqbrdcp2m21 | root | root@localhost | 2024-05-07 23:34:48 | adding row 2 on main |
| 38lpgag8jkbjo7l5gsmnfks4vgjqo6h3 | root | root@localhost | 2024-05-07 23:34:48 | adding row 1 on main |
| df42kstlos2i84c7vujnv6kofrudn332 | root | root@localhost | 2024-05-07 23:34:48 | adding table t on main |
| d0ltbo8su41muhftfg3gm6jr6re19jpt | jfulghum | jason.fulghum@gmail.com | 2024-05-07 23:29:01 | Initіаlіze datа rеpоsitory |
+----------------------------------+-----------+-------------------------+---------------------+------------------------------------+
from dolt.
Related Issues (20)
- [Question] How to ``init`` Dolt database programatically? HOT 2
- CLI `dolt fetch <remote>` failed to use the default `ref spec`
- `DESCRIBE <table>` should read indexes in order that they were defined
- Incorrect results for JSON lookups.
- Update with subquery join clause causes field index error/panic for table with trigger HOT 2
- Dolt panics on subquery in IF statement in procedure HOT 3
- Dolt panics when renaming index containing capital letters HOT 4
- Foreign keys disappear after merge for tables created with FOREIGN_KEY_CHECKS=0 HOT 7
- Dolt returns wrong number of affected rows for UPDATE ... JOIN with clientFoundRows=true HOT 2
- UPDATE ... JOIN fails for tables containing capital letters HOT 2
- Auto-generated FK names don't match MySQL for renamed tables HOT 3
- Auto-generated index names don't match MySQL for composite keys HOT 2
- error reading server preface: http2: frame too large HOT 9
- Add support for `DOLT_HASHOF_DB()` HOT 1
- NOT FOUND handlers in procedures cause ERROR 1105 (HY000): EOF
- Temporary tables don't support AUTO_INCREMENT
- `dolt pull` fails in the presence of ignored tables HOT 3
- Should be able to use "STAGED" as commits in `dolt_commit_diff_[tablename]` HOT 2
- Create a config.yaml file when database server is first run
- Clean up foreign key resolution
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 dolt.