Giter VIP home page Giter VIP logo

Comments (4)

arp242 avatar arp242 commented on June 26, 2024

There isn't really a way to fix this without manually altering the IDs; the first site you create is the main "account", and the other sites are linked to that by setting the parent column to that site ID.

This should really be split out in to an "account" and "site" table, or something, but it's a fairly large refactor. It doesn't use the "parent → child" terminology in the UI any more, but it's still in the code.

At any rate, you can set a new "account site" with something like:

update sites set parent=2 where parent=1;

You'll need to restart goatcounter, as sites are cached in memory.

from goatcounter.

arp242 avatar arp242 commented on June 26, 2024

Oh, you'll also need to update the users table:

update users set site_id=2 where site_id=1;

from goatcounter.

JenswBE avatar JenswBE commented on June 26, 2024

Thanks for above info! Changes worked fine.

A bit more verbose/structured procedure for future reference.

  1. Stop Goatcounter
  2. Start container with SQLite (if you don't have SQLite available)
sudo docker run --rm -v ${PATH_TO_GOATCOUNTER_DB:?}:/db.sqlite3 -it alpine
apk add sqlite
sqlite3 /db.sqlite
  1. Update DB
-- Nicer output
.mode table

-- Find new parent id
select site_id, parent, cname from sites;

-- Replace "parent=3" with new parent id and "parent=1" with old parent id
update sites set parent=3 where parent=1;

-- Validate new parent id
select site_id, parent, cname from sites;

-- Check users before change of parent site id
select user_id, site_id, email from users;

-- Replace "site_id=3" with new parent id and "site_id=1" with old parent id
update users set site_id=3 where site_id=1;

-- Validate changes to users
select user_id, site_id, email from users;
  1. Start Goatcounter again

from goatcounter.

arp242 avatar arp242 commented on June 26, 2024

It can just be changed to do the above automatically on deletion; that's actually much easier than splitting out the tables.

from goatcounter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.