Can I add an enabled-by-default lightswitch field to existing entries? I've created a lightswitch field that defaults to "On", and it works fine for new entries, but for all existing entries it is set to "Off". I'm keen to avoid having to manually go through all existing entries switching it to "On" - is there a way of making existing entries respect the default value of this new field (rather than treating the absence of a value for it from when they were created as "Off")?

(Or alternatively: is there an easy way to set a field to "On" for all existing entries?)
If there was no default set beforehand, then your previous elements will have a value of null for that field. You should be able to include those in your "on" queries by querying for that null value as well as the "on" value in your templates:

{% set onEntries = craft.entries.yourLightswitch([null, '1']).find %}


This won't actually change the value of your previous elements though. One way to do that would be using a SQL query against the craft_content table to update rows (elements) that have null in that column:

UPDATE `craft_content` SET `field_yourLightswitch` = 1 WHERE `field_yourLightswitch` IS NULL;