Skip to content

Add Sqlite option for PSReadline#4833

Open
jshigetomi wants to merge 9 commits intoPowerShell:masterfrom
jshigetomi:sqliteHistory
Open

Add Sqlite option for PSReadline#4833
jshigetomi wants to merge 9 commits intoPowerShell:masterfrom
jshigetomi:sqliteHistory

Conversation

@jshigetomi
Copy link
Contributor

@jshigetomi jshigetomi commented Jul 11, 2025

PR Summary

This pull request adds support for storing command history in a SQLite database as an alternative to the traditional text file in PSReadLine. It introduces new options for configuring history storage, updates the build and packaging process to include required SQLite dependencies, and makes the history system more flexible and extensible. The changes ensure that users can choose between text and SQLite-based history, and that the correct files are managed and loaded depending on the selected mode.

Key changes include:

SQLite History Support and Configuration:

  • Introduced a new HistoryType enum with options for Text and SQLite, and updated the PSConsoleReadLineOptions class to support selecting the history type (HistoryType property, defaulting to text). The active history save path is now determined by the selected type, with separate properties for text and SQLite paths (HistorySavePathText, HistorySavePathSQLite). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

  • Updated SetPSReadLineOption and internal logic to handle switching between history types, including initializing the SQLite database, migrating text history, and reloading history as needed. [1] [2]

  • Adjusted history reading and writing logic to respect the selected history type, including passing the current location for SQLite history entries and only reading the text history file if in text mode. [1] [2] [3]

Build and Packaging Updates:

  • Modified the build process to restructure native SQLite DLLs into a layout compatible with PowerShell's native DLL handler, and ensured all necessary managed and native SQLite dependencies are copied to the output and layout directories. [1] [2]

  • Updated project file to include Microsoft.Data.Sqlite and SQLitePCLRaw.bundle_e_sqlite3 as dependencies, and enabled CopyLocalLockFileAssemblies for proper DLL deployment.

  • Changed the NuGet configuration to use the official nuget.org feed.

User Interface and Testing:

  • Updated the format file to display the new history-related properties (HistoryType, HistorySavePathText, HistorySavePathSQLite) in the output.

  • Adjusted tests to use the new property names for history file paths. [1] [2] [3]

PR Context

This feature is discussed in issues: #3673 #1886

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure you've added one or more new tests
  • Make sure you've tested these changes in terminals that PowerShell is commonly used in (i.e. conhost.exe, Windows Terminal, Visual Studio Code Integrated Terminal, etc.)
  • User-facing changes
Microsoft Reviewers: Open in CodeFlow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant