alter table "Location" add column "Active" boolean default true;

-----------------------------------

alter table "Location" add column "PracticeId" int references "Practice"("PracticeId");
--select * from "Practice" p order by 1 desc;
--update "Location" set "PracticeId" = 26

---------


alter table "Provider" drop column "PracticeLocationId";


alter table "ProviderLocation" drop column "PracticeLocationId";

alter table "ProviderLocation" add column "LocationId" int references "Location"("LocationId"); 

--select * from "Location" ;

--update "ProviderLocation" set  "LocationId" = 2; 
alter table  "ProviderLocation" alter column "LocationId"  set not null;

alter table "Location" add column "CountryId" int references "Country"("CountryId");

select * from "Country";

update "Location" set "CountryId" = 1;

alter table  "Location" alter column "CountryId" set not null;

alter table "User" drop column "ProviderLocationId";

alter table "User" add column "ProviderLocationId" int references "ProviderLocation"("ProviderLocationId");
