-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
usuario incluye referencia a sip::persona
- Loading branch information
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class RelUsuarioPersona < ActiveRecord::Migration[5.1] | ||
def up | ||
add_column :usuario, :persona_id, :integer | ||
add_foreign_key :usuario, :sip_persona, column: :persona_id | ||
execute <<-SQL | ||
INSERT INTO sip_persona (id, nombres, apellidos, sexo) | ||
(SELECT id, nombres, apellidos, 'S' FROM usuario); | ||
UPDATE usuario SET persona_id=id; | ||
SQL | ||
end | ||
|
||
def down | ||
UPDATE usuario SET persona_id=NULL; | ||
DELETE FROM sip_persona; | ||
remove_foreign_key :usuario, :sip_persona, column: :persona_id | ||
remove_column :usuario, :persona_id, :integer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters