Last active
August 29, 2015 14:06
-
-
Save Batistleman/824905c931052fb4ec2e to your computer and use it in GitHub Desktop.
Meteor Migration Proposal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Post = new SimpleSchema({ | |
version: 1, | |
title: { | |
type: String, | |
label: "Title", | |
max: 200 | |
} | |
}); | |
Migrations.add({ | |
from_version: 1, | |
to_version: 2, | |
name: 'Adds "(oldpost) to every title', | |
up: function() { | |
to=from; | |
to.title = from.title + "(oldpost)"; | |
} | |
down: function() { | |
from=to; | |
//asuming the from object is what we want as the result | |
from.title = to.title.replace("(oldpost)", ""); | |
} | |
}); | |
Post = new SimpleSchema({ | |
version: 2, | |
title: { | |
type: String, | |
label: "Title", | |
max: 200 | |
} | |
}); | |
Migrations.add({ | |
from_version: 2, | |
to_version: 3, | |
name: 'The boss told me the title of the post should be called "name"...', | |
up: function() { | |
to=from; | |
to.name = from.title; | |
delete to.title; | |
} | |
down: function() { | |
from=to; | |
//asuming the from object is what we want as the result | |
from.title = to.name; | |
delete from.name; | |
} | |
}); | |
Post = new SimpleSchema({ | |
version: 3, | |
name: { | |
type: String, | |
label: "Name", | |
max: 200 | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment