Migrations¶
Forward-only SQL migration runner.
migrate ¶
Migration runner.
Forward-only by design. The runner:
- Discovers
*.sqlfiles under :mod:taskq.migrationsin lexicographic order, the naming convention is{ver}_{nn}_{pre|post}_{description}.sql. - Substitutes the
{schema}placeholder with the configured schema name. - Applies migrations not already recorded in
{schema}.schema_migrations, recording a SHA-256 checksum of the rendered SQL after each successful apply.
There is no down operation. To revert, restore from a database backup.
Published variants¶
An applied migration's ledger checksum must match the bundled file or the
runner refuses (checksum drift, fail-closed). The one exception: a file
whose bytes were amended after first shipping may exist in more than one
published version, and databases that applied the earlier bytes keep
that checksum forever. The _variants/ directory inside
:mod:taskq.migrations carries the published history (one file per
vintage, named for the commit that published it); the drift check accepts
a ledger checksum matching the current file or any bundled variant, each
rendered with the checking database's own schema. A checksum nothing
bundled produced is still drift. Variants are code: reviewed, bundled,
versioned — adding one is a PR, never a runtime knob.
Non-transactional migrations¶
By default each migration file runs inside its own transaction, so a failure
rolls the whole file back. Postgres forbids some statements inside a
transaction block, CREATE INDEX CONCURRENTLY, DROP INDEX
CONCURRENTLY, several ALTER TYPE/VACUUM forms, which makes them
inexpressible under the default wrapper. A migration can opt out by placing
the header directive -- taskq:no-transaction in its leading comment
block (-- line comments only, before the first SQL token); the runner
then executes the file statement by statement with no wrapping transaction
(Alembic's autocommit-block semantics). Two rules keep that safe:
- The migration must be idempotent and re-runnable, nothing rolls back, so a mid-file failure leaves earlier statements in place and the migration is re-executed on the next run. The ledger records completion only after every statement succeeds.
-
An interrupted
CREATE INDEX CONCURRENTLYleaves anINVALIDindex behind; the standard remedy is drop-and-rebuild, written into the migration itself::-- taskq:no-transaction -- not redundant with IF not EXISTS below: an interrupted CREATE INDEX -- CONCURRENTLY leaves an INVALID index that IF not EXISTS alone would -- silently skip rebuilding, so drop the debris first. DROP INDEX CONCURRENTLY IF EXISTS "{schema}".jobs_foo_idx; CREATE INDEX CONCURRENTLY IF not EXISTS jobs_foo_idx ON "{schema}".jobs (foo);
Transaction-control statements (BEGIN/COMMIT/ROLLBACK/...) are
rejected in non-transactional files, they would silently re-open a
transaction and, on failure, poison the caller's connection. Statement
splitting assumes standard_conforming_strings=on (the Postgres default
since 9.1).
The ledger column schema_migrations.use_transaction records how each
migration ran (false = outside a transaction) so operators can see which
migrations were/are safe to run online; the runner adds the column on first
use, so pre-upgrade ledgers need no dedicated migration.
__all__
module-attribute
¶
__all__ = [
"ApplyFailureDiagnosis",
"ChecksumDrift",
"ChecksumDriftError",
"Migration",
"MigrationConnectionError",
"MigrationLockTimeoutError",
"Phase",
"apply_pending",
"apply_pending_locked",
"checksum_drifts",
"diagnose_apply_failure",
"discover",
"list_applied",
"list_invalid_indexes",
"migration_advisory_lock",
"migration_lock_name",
"render",
"render_apply_failure_lines",
"split_statements",
]
DEFAULT_MIGRATION_DDL_LOCK_TIMEOUT
module-attribute
¶
Migration
dataclass
¶
Migration(
version: str,
phase: Phase,
description: str,
filename: str,
sql_template: str,
use_transaction: bool = True,
)
A single SQL migration file.
use_transaction
class-attribute
instance-attribute
¶
When False (-- taskq:no-transaction header directive), apply the
file statement by statement with no wrapping transaction. Postgres
requires this for CREATE INDEX CONCURRENTLY and friends, but nothing
rolls back on failure, so such migrations must be idempotent.
render ¶
MigrationLockTimeoutError ¶
Bases: RuntimeError
A migration run's DDL waited ddl_lock_timeout for a table lock and
gave up; its transaction rolled back and nothing was applied.
migration is the transactional migration whose DDL timed out, or
None when the wait was the runner's own upgrade of the
schema_migrations ledger (an ALTER TABLE that runs before the
first migration of a run, or after a -- taskq:no-transaction file's
statements). Raised in place of the driver's LockNotAvailableError
(kept as the cause) so the report names what waited, the bound that
expired, and the remedy, the holder must be found and ended, or the
bound raised, rather than the bare canceling statement due to lock
timeout.
Source code in src/taskq/migrate.py
MigrationConnectionError ¶
Bases: RuntimeError
A migration apply was handed a POOL where one asyncpg.Connection
belongs.
:func:apply_pending runs every migration on the CALLER'S connection
— the caller owns the transaction scope (the CLI wraps its own
ledger upgrade around it; a programmatic caller composes the apply
into a larger run). A Pool cannot serve that contract (it has no
transaction() — the apply would die the untyped
AttributeError at the first statement). The refusal NAMES the
Connection: acquire one from the pool and pass that.
Raised in place of the driver traceback so the setup defect reads
actionable, the same doctrine the client arm's
SchemaNotMigratedError translation keeps.
Source code in src/taskq/migrate.py
ChecksumDrift
dataclass
¶
One applied migration whose ledger checksum differs from the file.
key is the ledger identity ({version}:{phase}), stored is
the checksum recorded when the migration ran, current is the
checksum the bundled file renders to now.
ChecksumDriftError ¶
Bases: RuntimeError
An APPLIED migration's ledger checksum differs from the bundled file.
The ledger checksum is the SHA-256 of the SQL as it ran; a mismatch means the file no longer matches the schema the database actually has. Applying further migrations on top would build on an unverified premise (the recorded schema may not be what the current files produce, so the next file's assumptions can be silently wrong), which is why the runner refuses by default instead of warning and continuing. not-YET-APPLIED files cannot drift: nothing is recorded for them yet.
Remedies: restore the migration file to the version that actually ran
(editing an already-applied migration is never picked up, forward-only
by design), or, after verifying the edited file is exactly what the
database already has (or that the edit is safe to build on), pass
allow_checksum_drift=True (the CLI's --allow-checksum-drift)
to proceed past the refusal. The drift is still logged as a warning
either way, the ledger keeps the stored checksum.
Source code in src/taskq/migrate.py
ApplyFailureDiagnosis
dataclass
¶
ApplyFailureDiagnosis(
headline: str,
failed_filename: str | None,
use_transaction: bool | None,
invalid_indexes: tuple[str, ...],
schema: str,
guard_rejected: bool = False,
)
Self-diagnosis of a failed migration apply, gathered on the still-open
connection by :func:diagnose_apply_failure and rendered by
:func:render_apply_failure_lines.
headline
instance-attribute
¶
First line of the original error (asyncpg messages can be multiline).
failed_filename
instance-attribute
¶
Filename of the migration that failed, taken from the exception's
taskq_failed_migration tag when :func:apply_pending attached one,
else the first unrecorded migration in discover() order (a heuristic
that misattributes under --phase); None when it could not be
determined.
use_transaction
instance-attribute
¶
Migration.use_transaction of the failed migration; None when
the failed migration could not be determined.
invalid_indexes
instance-attribute
¶
INVALID indexes in the schema, debris of an interrupted CREATE
INDEX CONCURRENTLY; only gathered for no-transaction failures.
guard_rejected
class-attribute
instance-attribute
¶
True when the failure was the transaction-control guard refusing the
file (:func:_reject_transaction_control) rather than a statement
failing mid-file, read from the exception's taskq_guard_rejection
tag. The report then says nothing was executed and that the fix is
removing the statement, instead of the generic no-transaction wording
("statements before the failure remain applied", "re-run, the
migration is idempotent"), both false for a guard rejection.
__post_init__ ¶
Source code in src/taskq/migrate.py
discover ¶
Return all bundled migrations sorted by version, then pre before post.
Raises :class:ValueError when two bundled files map to one ledger
identity (see :func:_refuse_duplicate_ledger_keys).
Source code in src/taskq/migrate.py
render ¶
Substitute {schema} in a SQL template.
SQL files escape literal curly braces by doubling them ({{ → {)
because :func:str.format is the substitution engine.
Source code in src/taskq/migrate.py
split_statements ¶
Split a SQL script into individual statements, without their ;.
Non-transactional migrations are executed statement by statement: a
multi-statement string sent through Postgres' simple query protocol runs
as one implicit transaction, which would defeat the point (CREATE
INDEX CONCURRENTLY would still be "inside a transaction block").
Splitting understands single-quoted strings (including E'...'
backslash escapes and '' doubling), "..."-quoted identifiers,
-- line comments, nested /* ... */ block comments, and
dollar-quoted bodies ($$...$$ / $tag$...$tag$). Leading comments
stay attached to the statement that follows them; comment-only chunks
are dropped. Unterminated constructs yield one trailing chunk, leaving
the syntax error to Postgres, same as executing the file whole.
Source code in src/taskq/migrate.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
list_applied
async
¶
Return {version}:{phase} keys recorded in schema_migrations.
Returns an empty set if the schema or table does not yet exist, a
fresh database is the common case on first migrate up.
Source code in src/taskq/migrate.py
checksum_drifts
async
¶
Compare the ledger's recorded checksums against the bundled files.
Returns one :class:ChecksumDrift per APPLIED migration whose stored
checksum differs from what its file renders to now, keyed by the
migration key, empty when the ledger and the files agree (or when no
ledger exists yet). Shared by migrate up's fail-closed refusal
(:func:apply_pending) and migrate status's drift report, so both
surfaces answer with the same comparison.
A drifted checksum means the file no longer matches the SQL that built the schema: the file was edited after it ran, or the ledger was tampered with. Neither is recoverable by applying more migrations, which is why callers should surface the result prominently rather than bury it among pending entries.
Source code in src/taskq/migrate.py
list_invalid_indexes
async
¶
Return the names of INVALID indexes in schema, sorted by name.
An interrupted CREATE INDEX CONCURRENTLY leaves an INVALID index
behind: the query planner ignores it, but writers still maintain it, so
it is pure overhead (and blocks the re-run's IF not EXISTS). The CLI
surfaces these in its failure report so users never have to query the
catalogs by hand.
Source code in src/taskq/migrate.py
apply_pending
async
¶
apply_pending(
conn: Connection | Pool,
*,
schema: str,
phase: Phase | None = None,
target: str | None = None,
max_steps: int | None = None,
ddl_lock_timeout: float = DEFAULT_MIGRATION_DDL_LOCK_TIMEOUT,
allow_checksum_drift: bool = False,
_pg_capabilities: PgCapabilities | None = None,
prefer_sql: bool = False,
_transactional_scratch: bool = False,
) -> list[Migration]
Apply pending migrations.
Takes one :class:asyncpg.Connection — the caller's transaction
scope. A :class:asyncpg.Pool is the typed
:class:MigrationConnectionError refusal (the Pool cannot serve the
apply's own transaction management — acquire a connection and pass
that).
Each migration runs in its own transaction so a failure in one file does
not leave a half-applied schema, unless the file carries the
-- taskq:no-transaction header directive (:attr:Migration.use_transaction),
in which case it is executed statement by statement with no wrapping
transaction. That unlocks CREATE INDEX CONCURRENTLY and friends, but
nothing rolls back on failure: prior statements stay applied, the
migration is not recorded in the ledger, and it will be re-executed on
the next run, so non-transactional migrations must be idempotent.
:param phase: restrict to pre or post migrations only.
:param target: stop after applying this version (inclusive). Must
name a version in the discovered set: an unknown target, a
deleted or renumbered migration, raises ValueError rather
than silently applying every pending migration.
:param max_steps: stop after this many applies.
:param ddl_lock_timeout: seconds a transactional migration may wait for
a table lock (:data:DEFAULT_MIGRATION_DDL_LOCK_TIMEOUT); applied
as SET LOCAL lock_timeout inside each migration's own
transaction, so it never outlives the migration, and never applied
to -- taskq:no-transaction files, whose CONCURRENTLY waits
are heavyweight-lock waits by design. A wait that outlives it
raises :class:MigrationLockTimeoutError; 0 waits indefinitely
(stated explicitly, so a session-level lock_timeout default
cannot bound the wait either); negative, non-finite, and
sub-millisecond values are refused with ValueError.
:param _transactional_scratch: internal seam for
:func:taskq.timescale.disable_hypertables. When true, a
-- taskq:no-transaction file's statements run inside one
caller-transaction savepoint instead of autocommit, with
CONCURRENTLY dropped from index DDL (the private scratch schema the
caller rebuilds is empty, so the plain form is equivalent). PostgreSQL
still refuses any other non-transactional statement, loudly.
:param allow_checksum_drift: proceed past :class:ChecksumDriftError
when an APPLIED migration's ledger checksum differs from the
bundled file. The drift is still logged as a warning. not-YET-
APPLIED files cannot drift (nothing is recorded for them yet), so
this flag never changes which migrations run, only whether a
drifted ledger refuses the run.
:param prefer_sql: ask the server for its version instead of trusting the
connection's startup metadata (see probe_pg_capabilities). Set it
when this connection's DSN may sit behind a transaction-mode pooler,
whose startup answer is not evidence about the server behind it.
:returns: migrations that were applied (in order).
:raises ChecksumDriftError: when an applied migration's stored checksum
differs from the file and allow_checksum_drift is False.
Raised before anything is applied: a ledger that no longer matches
the files means the schema's provenance is unverified, and further
migrations must not build on it.
:raises UnsupportedPostgresVersionError: when the server is older than
TaskQ's PostgreSQL floor. Raised before anything is applied, so an
unsupported major fails here, naming the detected version and the
upgrade remedy, instead of on the first PG 18-only statement.
Source code in src/taskq/migrate.py
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 | |
migration_lock_name ¶
Schema-qualified migration advisory-lock name: taskq:migrate:{schema}.
Advisory locks live in a per-database namespace, so the pre-qualification
fixed bigint key was shared by every schema in the database: two
deployments sharing one database serialized their migrations on one
lock, and the loser of a cross-deployment race, a schema with
nothing to migrate, burned its bounded startup wait and SystemExited
while an unrelated schema's long DDL ran. Qualifying with the schema
gives each schema its own lock; same-schema replicas still serialize
(the reason the lock exists, a virgin schema's bare CREATE TABLE
races two concurrent appliers).
Deliberately the same taskq:{purpose}:{schema} shape as
:func:taskq.constants.schema_lock_name (built from it). That helper
is how every purpose lock in the system derives its key, one lock
per schema and purpose (maintenance_leader, prune, archive_expiry,
cron, migrate). Keyed locks, which must distinguish a resource
within a schema, embed the schema before their key instead: the
sliding-window bucket lock taskq:{schema}:sw:{name} (mirroring
the bucket's Redis key) and the enqueue unique-for lock
taskq:unique_for:{schema}:{actor}:{identity_key}. Both
conventions qualify with the schema; they differ only in where the
distinguishing key segments sit.
Upgrade discipline: the qualified key replaces the unqualified bigint outright, a mixed old/new fleet holds different keys, so an old and a new replica can apply migrations to the same schema concurrently during the deploy window. Adopt by restarting the fleet onto the new release rather than rolling it; the window is the deploy, not the steady state. (Same caveat as the schema-qualified leader locks.)
Source code in src/taskq/migrate.py
diagnose_apply_failure
async
¶
Gather a self-diagnosis of a failed apply on the still-open conn.
Both apply paths leave the connection reusable (a transactional failure
rolls back; the no-transaction path never opened one), so the same conn
can report what failed and what state the schema is in. Diagnosis must
never mask the original error: every read is individually suppressed,
and whatever could not be gathered degrades to the generic report
(failed_filename=None).
Source code in src/taskq/migrate.py
render_apply_failure_lines ¶
Render a diagnosis as report lines (CLI stderr / startup SystemExit).
startup=False reproduces the migrate up CLI report verbatim;
startup=True swaps only the action line for the restart-safe
variant (:data:_STARTUP_ACTION_LINE), except for guard rejections,
where neither action line is truthful (nothing executed, and re-run or
restart fails identically until the statement is removed), so the
guard branch renders the same remove-and-rerun guidance either way.
Source code in src/taskq/migrate.py
migration_advisory_lock
async
¶
migration_advisory_lock(
conn: Connection,
lock_timeout: float = DEFAULT_MIGRATION_LOCK_TIMEOUT,
*,
schema: str,
prefer_sql: bool = False,
) -> AsyncGenerator[None]
Hold schema's migration advisory lock and yield None.
The PostgreSQL floor is checked before session state changes or the lock wait. The lock/reset/release protocol is shared with the internal migration runners, which additionally reuse the probe's capability answer. prefer_sql asks the server for its version when the connection reaches it through a pooler whose startup metadata cannot be trusted.
Source code in src/taskq/migrate.py
apply_pending_locked
async
¶
apply_pending_locked(
dsn: str | None = None,
*,
schema: str,
phase: Phase | None = "pre",
target: str | None = None,
max_steps: int | None = None,
conn: Connection | None = None,
conn_factory: Callable[[], Awaitable[Connection]]
| None = None,
lock_timeout: float = DEFAULT_MIGRATION_LOCK_TIMEOUT,
ddl_lock_timeout: float = DEFAULT_MIGRATION_DDL_LOCK_TIMEOUT,
allow_checksum_drift: bool = False,
direct_tls: bool = False,
prefer_sql: bool = False,
connect_timeout: float = DEFAULT_PG_CONNECT_TIMEOUT,
) -> list[Migration]
Apply pending migrations under a session-level advisory lock.
Acquires pg_advisory_lock to prevent concurrent startup races,
applies pending migrations, and releases the lock.
connect_timeout bounds the dsn source's TCP/TLS handshake per host
(TASKQ_PG_CONNECT_TIMEOUT); the other two sources bring their own
connection. Without it a black-holed endpoint costs asyncpg's 60 s
default before startup gives up, on the very path a rollout waits on.
prefer_sql asks the server for its version instead of trusting the
startup packet's (see probe_pg_capabilities): the one-shot CLI/UI
connection dials the configured DSN, which the operator's pg_is_pooled
declaration says may be a transaction-mode pooler whose startup answer is
not evidence about the server behind it.
lock_timeout bounds the capability probe and the wait for the
advisory lock, the latter via Postgres' lock_timeout GUC. The GUC is
reset to unlimited before the migrations run; each transactional migration
then bounds its own table-lock waits with ddl_lock_timeout (see
:func:apply_pending), which cannot interrupt a statement that already
holds its lock. Pass 0 to wait indefinitely for both the probe and lock
(the old behaviour).
The session's statement_timeout and transaction_timeout are
widened to unlimited for the apply phase for the same reason: caller-
or role-supplied defaults must not abort a long DDL statement or kill
its session mid-build (either would fail identically on every retry).
Losing the race raises :class:SystemExit naming the contention, rather
than hanging until the platform kills the container.
allow_checksum_drift passes through to :func:apply_pending: a
ledger checksum that no longer matches the bundled files refuses the
run (as :class:ChecksumDriftError, converted to SystemExit by
this wrapper's failure handling) unless the flag is set. Startup
callers (--migrate, TASKQ_MIGRATE_ON_START) should leave it
False: a drifted ledger is exactly the state a fleet must not start
on.
Connection sources (mutually exclusive):
* conn, pre-constructed, caller-owned; not closed here.
* conn_factory, zero-arg async factory; closed in finally.
* dsn, asyncpg.connect(dsn); closed in finally.
direct_tls applies to the dsn source only (the caller owns the
credential and transport of the other two): it opts the migration
connection into PostgreSQL direct TLS and validates the DSN's sslmode
through :func:taskq.connections.direct_tls_kwargs, so a migrate-on-start
path never negotiates a different TLS mode than the pools it precedes.
Raises :class:SystemExit on failure so the calling process aborts
cleanly. This is the recommended entry point for CLI --migrate
and admin sidecar TASKQ_MIGRATE_ON_START paths.
One failure keeps its typed form: a server below TaskQ's PostgreSQL
floor raises :class:UnsupportedPostgresVersionError out of this
wrapper rather than being converted. The diagnosis machinery below
reports schema state, which says nothing useful about a server that
is merely too old, and the typed error already carries the actionable
remedy.
phase defaults to "pre" because this entry point fires on
process lifecycle events nobody sequences, a pod restart, a rollout,
an autoscale event, not on an operator's decision. A post-phase
migration exists precisely to be withheld until the whole fleet is
confirmed upgraded, and no single process can know that, so applying
one here would let a restart close a rolling-deploy overlap window
mid-rollout. Dropping the old single-column idempotency index while
the not-yet-upgraded half of the fleet is still issuing
ON CONFLICT (idempotency_key) takes that half's ENTIRE enqueue
path down: the arbiter index is resolved at plan time, so every
enqueue fails regardless of row values. The post phase stays behind
the operator's explicit taskq migrate up --phase post; pass
phase=None to apply every phase from a context that has that
knowledge.
Source code in src/taskq/migrate.py
1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 | |