# Version

An instance of a Version class can only be returned from the Dexie.version() method. Use it to define the schema and any upgrader function for that specific version.

#### Sample

```javascript
var db = new Dexie("FriendsAndPetsDatabase");
db.version(2).stores({
  friends: "++id,name,birthdate,sex",
  pets: "++id,name,kind"
}).upgrade (trans => {
  var YEAR = 365 * 24 * 60 * 60 * 1000;
  return trans.friends.toCollection().modify (friend => {
    friend.birthdate = new Date(Date.now() - (friend.age * YEAR));
    delete friend.age;
  });
});
// Always keep the declarations previous versions as long as there might be users having them running.
db.version(1).stores({
  friends: "++id,name,age,sex",
  pets: "++id,name,kind"
});
db.open(); 
```

### Methods

#### [stores()](/version/version.stores.md)

Specify the database schema (object stores and indexes) for a certain version.

#### [upgrade()](/version/version.upgrade.md)

Specify an upgrade function for upgrading between previous version to this one.

### See Also

Database Versioning


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dexiejs.typogram.co/version.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
