I have create a contract, deployed it and used. My contract has created 4 blocks as of now. Now i want to change the signature of one of my function. so after doing so i need to re-deploy my contract. After re-deploying my contract will start creating the blocks from number 0 again. How do i make my new contract link to the previous block i have created and continue building on that chain.
For example, I have a contract with below function.
function createStudents(string fname, string year, string hash, uint256 _ipfsHash) public {
Student memory student = Student(fname, year, hash);
students.push(student);
studentInfo(fname, year, hash);
ipfsHash.push(_ipfsHash);
}
this function is pushing value in public variable Students. After deploying the above contract when i call the function the new value is getting pushed and my transaction data is stored in the block (i am using Ganache). So for example if i have called this function 3 times then each time i call, it will push the value in the variable and stores my transaction in the block. Now after pushing values for 3 times, i want to change the year parameter from string to uint256 for some business reason. So after changing the signature of the function i re-deployed the code. After re-deploy the contract address and ABI is changed so i updated my code. Now when i call the same function it is pushing the values in the same variable but i lost the transactions which i pushed before the re-deployment. So i wanted to know is there any way i can have my old data and create new data on top of that. For example if pushed 2000, 2001, 2002, before re-deploying then i would like to have them and my new push should get on top of that. Since the contract address itself has changed i am not sure if this is even possible. But i am thinking about real time problem where will need to change the functions based on the business logic but then in this case how do you get your old data.
I am new in this technology stack.
thanks for your help.