# Truffle Migration check for existing deployment before upgrading?

**URL:** <https://forum.openzeppelin.com/t/truffle-migration-check-for-existing-deployment-before-upgrading/5727>\
**Category:** Upgrades\
**Tags:** upgrades-plugins\
**Created:** [February 9, 2021, 2:53pm UTC](https://forum.openzeppelin.com/t/truffle-migration-check-for-existing-deployment-before-upgrading/5727 "2021-02-09T14:53:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Homer](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/homer/32/4254_2.png) [@Homer](https://forum.openzeppelin.com/u/Homer)\
**Post date:** [February 9, 2021, 2:53pm UTC](https://forum.openzeppelin.com/t/truffle-migration-check-for-existing-deployment-before-upgrading/5727/1 "2021-02-09T14:53:50Z")

</div>

I would like to write the following logic in the migration script for my truffle project with upgradeable contracts:

```
if(contract is not yet deployed) {
   const mynewcontract = deployProxy(MyContract, {deployer});
} else {
   const myupgradedcontract = upgradeProxy(MyContract, {deployer});
}

```

How can I handle that or how can I check in the migration script if the contract has already been deployed?

---

<div class="post-metadata">

**Author:** ![Homer](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/homer/32/4254_2.png) [@Homer](https://forum.openzeppelin.com/u/Homer)\
**Post date:** [February 10, 2021, 5:00pm UTC](https://forum.openzeppelin.com/t/truffle-migration-check-for-existing-deployment-before-upgrading/5727/2 "2021-02-10T17:00:02Z")

</div>

Check by

`MyContract.isDeployed()`

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [February 11, 2021, 2:48am UTC](https://forum.openzeppelin.com/t/truffle-migration-check-for-existing-deployment-before-upgrading/5727/3 "2021-02-11T02:48:43Z")

</div>

Hi @Homer,

Welcome to the community 👋

When you deploy using `deployProxy` the OpenZeppelin Upgrade Plugins track if the implementation contract, ProxyAdmin and proxy have already been deployed and if they haven’t will deploy.

Can you share a bit more information on your use case?
