truffle migrate only migrating first contract, not the second

450 Views Asked by At

the command "truffle migrate" works properly (no errors) but only migrates "Migrations.sol". It does not even attempt to migrate with 2_deploy_contracts.js

1_initial_migration.js :

var Migrations = artifacts.require("./Migrations.sol");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

Migrations.sol:

enter code herepragma solidity ^0.4.25;

contract Migrations {
  address public owner;
  uint public last_completed_migration;

  modifier restricted() {
    if (msg.sender == owner) _;
  }

  function Migration() public {
    owner = msg.sender;
  }

  function setCompleted(uint completed) restricted public{
    last_completed_migration = completed;
  }

  function upgrade(address new_address) restricted public{
    Migrations upgraded = Migrations(new_address);
    upgraded.setCompleted(last_completed_migration);
  }
}

2_deploy_contracts.js:

var Election = artifacts.require("./Election.sol");

module.exports = function(deployer) {
  deployer.deploy(Election);
};

Election.sol:

pragma solidity ^0.4.25;

contract Election {
  // Store candidate
  // Read candidate
  string public candidate;

  // Constructor
  // Our constructor will be run when the contract gets deployed, so must be public
  constructor() public{
      candidate = "Candidate 1";
  }
}
1

There are 1 best solutions below

0
Johnny521 On

Solution: I deleted my project folder and rebuilt it. This fixed it. Not sure exactly what the issue was.