i've been studying solidity/blockchain for a few months now and recently started development on a personal project. I have a few questions i kept running into, specifically when deploying contracts with truffle/ganache. After successfully compiling my contracts and updating the truffle-config.js file to deploy the contracts to my local blockchain, one of the common issues i ran into was that every time i ran "truffle migrate" on my terminal (after i initially ran 'truffle migrate --reset'), it would re-deploy my contracts despite it already being deployed earlier to the same local blockchain instance. My understanding from reading the truffle suite documentation is that, "truffle migrate --reset", will deploy contracts as if it were the first time, while "truffle migrate" will only deploy non-deployed contracts in my migrations folder however this is not the case. I updated my migrations code to handle this with try/catch statements, but instead the contracts would never deploy when restarting my local blockchain. I'm trying to understand why, despite not getting errors, the contract is not deployed successfully. Below I have a simple version of what my update migration js file looks like (constructor has one address parameter of a different contract). Apologies in advance, if some parts are not clear.
const AnotherContract= artifacts.require("./AnotherContract.sol");
module.exports = async function (deployer) {
let anotherContractInstance= await AnotherContract.deployed();
deployer.deploy(Contract, anotherContractInstance.address);
};
Q's: .Does truffle always re-deploy already deployed contracts when running "truffle migrate"? .If so is there a different command or changes that can be made so deployed contracts aren't re-deployed, for example, if we add a new and I need to run the migration file to deploy it? .Should I approach the migration file, as if im only running it once? If so, at least from a testing standpoint, would i need to restart my local blockchain anytime i make changes?