Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreign Key references don't get committed properly for tables #734

Open
fulghum opened this issue Sep 23, 2024 · 0 comments
Open

Foreign Key references don't get committed properly for tables #734

fulghum opened this issue Sep 23, 2024 · 0 comments
Labels
bug Something isn't working workbench Issue related to dolt-workbench

Comments

@fulghum
Copy link
Contributor

fulghum commented Sep 23, 2024

When following the Getting Started Guide, the table with foreign key references does not get committed properly and continues to show up in dolt_status as a schema change with the FK references added.

create table employees (id int8, last_name text, first_name text, primary key(id));
create table teams (id int8, team_name text, primary key(id));
create table employees_teams(team_id int8, employee_id int8, primary key(team_id, employee_id), foreign key (team_id) references teams(id), foreign key (employee_id) references employees(id));

call dolt_add('employees', 'teams', 'employees_teams');
call dolt_commit('-am', 'committing tables');

After the above commands, dolt_status should be empty, but it still shows employees_teams as having a schema modification:

 select * from dolt_status;
   table_name    | staged |  status  
-----------------+--------+----------
 employees_teams |      0 | modified

select * from dolt_diff where table_name='employees_teams';
           commit_hash            |   table_name    | committer |       email        |        date         |      message      | data_change | schema_change 
----------------------------------+-----------------+-----------+--------------------+---------------------+-------------------+-------------+---------------
 WORKING                          | employees_teams |           |                    |                     |                   |           0 |             1
 drselobrs1epj3ivmtpc0bgmo8on5gid | employees_teams | doltgres  | doltgres@127.0.0.1 | 2024-09-23 17:12:57 | committing tables |           0 |             1

 select * from dolt_patch('WORKING', 'HEAD');
 statement_order | from_commit_hash |          to_commit_hash          |   table_name    | diff_type |                                statement                                 
-----------------+------------------+----------------------------------+-----------------+-----------+--------------------------------------------------------------------------
               1 | WORKING          | drselobrs1epj3ivmtpc0bgmo8on5gid | employees_teams | schema    | ALTER TABLE `employees_teams` DROP FOREIGN KEY `employees_teams_ibfk_1`;
               2 | WORKING          | drselobrs1epj3ivmtpc0bgmo8on5gid | employees_teams | schema    | ALTER TABLE `employees_teams` DROP FOREIGN KEY `employees_teams_ibfk_2`;
@fulghum fulghum added the bug Something isn't working label Sep 23, 2024
@tbantle22 tbantle22 added the workbench Issue related to dolt-workbench label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working workbench Issue related to dolt-workbench
Projects
None yet
Development

No branches or pull requests

2 participants